Author: rich Date: Wed Jan 19 02:05:34 2005 New Revision: 125603 URL: http://svn.apache.org/viewcvs?view=rev&rev=125603 Log: Checkpoint for support of nested page flows in popup windows, and for mapping values back to the original window through JavaScript. More info when this is finalized...
DRT/BVT: netui (WinXP) BB: self (linux) Added: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ViewRenderer.java (contents, props changed) incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ConfigurePopup.java (contents, props changed) incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/IHasPopupSupport.java (contents, props changed) incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/IPopupSupport.java (contents, props changed) incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/PopupHelper.java (contents, props changed) incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RetrievePopupOutput.java (contents, props changed) incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/internal/IIdProvider.java (contents, props changed) incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/internal/ReturnActionViewRenderer.java (contents, props changed) incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/rendering/ResponseRenderAppender.java (contents, props changed) Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FlowControllerChecker.java incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FlowControllerInfo.java incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/JpfLanguageConstants.java incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/MergedControllerAnnotation.java incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/diagnostics.properties incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/genmodel/GenSimpleActionModel.java incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/ActionModel.java incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/AutoRegisterActionServlet.java incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowController.java incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ForwardHandler.java incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowController.java incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/annotations/Jpf.java incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/config/PageFlowActionMapping.java incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/BackingClassMethodBinding.java incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowActionListener.java incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalConstants.java incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/RequestValues.java incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ServerAdapterManager.java incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/script/common/ImplicitObjectUtil.java incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/invoke/CallPageFlow.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractClassicTag.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/AnchorBase.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/JavaScriptUtils.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ScriptHeader.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/javaScript.properties incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/DiscoveryUtils.java incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FlowControllerChecker.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FlowControllerChecker.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FlowControllerChecker.java&r1=125602&p2=incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FlowControllerChecker.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FlowControllerChecker.java (original) +++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FlowControllerChecker.java Wed Jan 19 02:05:34 2005 @@ -148,7 +148,7 @@ // Runtime performance enhancement: enable saving of previous-page and previous-action information based on // whether there were Forwards that contained navigateTo attributes. // - enableNavigateTo( jclass, _fcInfo ); + enableNavigateTo( jclass, _fcInfo.getMergedControllerAnnotation(), _fcInfo ); Map< String, TypeDeclaration > sharedFlowTypes = _fcInfo.getSharedFlowTypes(); if ( sharedFlowTypes != null ) @@ -159,7 +159,7 @@ // Saving of previous-page/previous-action info must be enabled if any of the referenced shared flows // use this feature. // - enableNavigateTo( sharedFlowType, _fcInfo ); + enableNavigateTo( sharedFlowType, new MergedControllerAnnotation( sharedFlowType ), _fcInfo ); } } @@ -168,13 +168,14 @@ return _checkResultMap; } - private static void enableNavigateTo( TypeDeclaration flowControllerClass, FlowControllerInfo fcInfo ) + private static void enableNavigateTo( TypeDeclaration flowControllerClass, MergedControllerAnnotation controllerAnn, + FlowControllerInfo fcInfo ) { // // Look through Forwards and SimpleActions in the Controller annotation. // - enableNavigateTo( fcInfo.getMergedControllerAnnotation().getForwards(), fcInfo ); - enableNavigateTo( fcInfo.getMergedControllerAnnotation().getSimpleActions(), fcInfo ); + enableNavigateTo( controllerAnn.getForwards(), fcInfo ); + enableNavigateTo( controllerAnn.getSimpleActions(), fcInfo ); // // Look through Forwards on Action and ExceptionHandler methods. @@ -371,7 +372,7 @@ getDiagnostics().addWarning( pathVal, "warning.inherited-file-not-found", path, ANNOTATION_INTERFACE_PREFIX + ann.getAnnotationType().getDeclaration().getSimpleName(), - baseType ); + baseType.getQualifiedName() ); } } } Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FlowControllerInfo.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FlowControllerInfo.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FlowControllerInfo.java&r1=125602&p2=incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FlowControllerInfo.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FlowControllerInfo.java (original) +++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FlowControllerInfo.java Wed Jan 19 02:05:34 2005 @@ -127,8 +127,7 @@ void startBuild( AnnotationProcessorEnvironment env, ClassDeclaration jclass ) { _isBuilding = true; - _mergedControllerAnnotation = new MergedControllerAnnotation(); - mergeControllerAnnotations( _mergedControllerAnnotation, jclass ); + _mergedControllerAnnotation = new MergedControllerAnnotation( jclass ); _isNested = _mergedControllerAnnotation.isNested(); setSharedFlowInfo( env ); } @@ -343,19 +342,5 @@ public boolean isNavigateToPageEnabled() { return _navigateToPageEnabled; - } - - private static void mergeControllerAnnotations( MergedControllerAnnotation ann, ClassDeclaration jclass ) - { - // - // Merge in all the controller annotations, starting with the most remote superclass first. - // - if ( jclass != null ) - { - ClassType superClass = jclass.getSuperclass(); - if ( superClass != null ) mergeControllerAnnotations( ann, superClass.getDeclaration() ); - AnnotationMirror controllerAnnotation = CompilerUtils.getAnnotation( jclass, CONTROLLER_TAG_NAME ); - if ( controllerAnnotation != null ) ann.mergeAnnotation( controllerAnnotation ); - } } } Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/JpfLanguageConstants.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/JpfLanguageConstants.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/JpfLanguageConstants.java&r1=125602&p2=incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/JpfLanguageConstants.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/JpfLanguageConstants.java (original) +++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/JpfLanguageConstants.java Wed Jan 19 02:05:34 2005 @@ -163,6 +163,7 @@ public static final String MULTIPART_HANDLER_ATTR = "multipartHandler"; public static final String SHARED_FLOW_REFS_ATTR = "sharedFlowRefs"; public static final String PREVENT_DOUBLE_SUBMIT_ATTR = "preventDoubleSubmit"; + public static final String FORWARD_REF_ATTR = "forwardRef"; public static final String MIN_INT_ATTR = "minInt"; public static final String MAX_INT_ATTR = "maxInt"; Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/MergedControllerAnnotation.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/MergedControllerAnnotation.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/MergedControllerAnnotation.java&r1=125602&p2=incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/MergedControllerAnnotation.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/MergedControllerAnnotation.java (original) +++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/MergedControllerAnnotation.java Wed Jan 19 02:05:34 2005 @@ -18,6 +18,9 @@ package org.apache.beehive.netui.compiler; import com.sun.mirror.declaration.AnnotationMirror; +import com.sun.mirror.declaration.ClassDeclaration; +import com.sun.mirror.declaration.TypeDeclaration; +import com.sun.mirror.type.ClassType; import java.util.List; import java.util.LinkedHashMap; @@ -43,6 +46,11 @@ private LinkedHashMap< String, AnnotationMirror> _messageResources = new LinkedHashMap< String, AnnotationMirror >(); private String _multipartHandler; + public MergedControllerAnnotation( TypeDeclaration jclass ) + { + mergeControllerAnnotations( jclass ); + } + public void mergeAnnotation( AnnotationMirror controllerAnnotation ) { String strutsMerge = CompilerUtils.getString( controllerAnnotation, STRUTSMERGE_ATTR, true ); @@ -180,5 +188,19 @@ public String getMultipartHandler() { return _multipartHandler; + } + + private void mergeControllerAnnotations( TypeDeclaration jclass ) + { + // + // Merge in all the controller annotations, starting with the most remote superclass first. + // + if ( jclass != null && jclass instanceof ClassDeclaration ) + { + ClassType superClass = ( ( ClassDeclaration ) jclass ).getSuperclass(); + if ( superClass != null ) mergeControllerAnnotations( superClass.getDeclaration() ); + AnnotationMirror controllerAnnotation = CompilerUtils.getAnnotation( jclass, CONTROLLER_TAG_NAME ); + if ( controllerAnnotation != null ) mergeAnnotation( controllerAnnotation ); + } } } Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/diagnostics.properties Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/diagnostics.properties?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/diagnostics.properties&r1=125602&p2=incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/diagnostics.properties&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/diagnostics.properties (original) +++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/diagnostics.properties Wed Jan 19 02:05:34 2005 @@ -98,6 +98,7 @@ error.empty-string-not-allowed = This value may not be an empty string. error.nested-long-lived = A nested page flow may not be long-lived. warning.unresolvable-forward = There is no forward named "{0}" declared on this method or on this class. +error.unresolvable-global-forward = There is no forward named "{0}" declared on this class. error.validation-field-on-non-getter = This annotation may only be present on a public, non-static getter method. Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/genmodel/GenSimpleActionModel.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/genmodel/GenSimpleActionModel.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/genmodel/GenSimpleActionModel.java&r1=125602&p2=incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/genmodel/GenSimpleActionModel.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/genmodel/GenSimpleActionModel.java (original) +++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/genmodel/GenSimpleActionModel.java Wed Jan 19 02:05:34 2005 @@ -65,13 +65,22 @@ { // // First add the default forward -- the one that is parsed from the simple action annotation itself. + // But, if the "forwardRef" attribute was given, simply use the one referenced. // - ForwardModel fwd = new SimpleActionForward( DEFAULT_SIMPLE_ACTION_FORWARD_NAME, parentApp, annotation, jclass ); + String forwardRef = CompilerUtils.getString( annotation, FORWARD_REF_ATTR, true ); - if ( fwd.getPath() != null || fwd.isReturnToAction() || fwd.isReturnToPage() || fwd.isNestedReturn() ) + if ( forwardRef == null ) { - addForward( fwd ); + forwardRef = DEFAULT_SIMPLE_ACTION_FORWARD_NAME; + ForwardModel fwd = new SimpleActionForward( forwardRef, parentApp, annotation, jclass ); + + if ( fwd.getPath() != null || fwd.isReturnToAction() || fwd.isReturnToPage() || fwd.isNestedReturn() ) + { + addForward( fwd ); + } } + + setDefaultForwardName( forwardRef ); List< AnnotationMirror > conditionalFwdAnnotations = CompilerUtils.getAnnotationArray( annotation, CONDITIONAL_FORWARDS_ATTR, true ); Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java&r1=125602&p2=incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java (original) +++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java Wed Jan 19 02:05:34 2005 @@ -27,20 +27,33 @@ import com.sun.mirror.declaration.AnnotationMirror; import com.sun.mirror.declaration.MemberDeclaration; import com.sun.mirror.declaration.TypeDeclaration; +import com.sun.mirror.declaration.AnnotationTypeElementDeclaration; +import com.sun.mirror.declaration.AnnotationValue; import static org.apache.beehive.netui.compiler.JpfLanguageConstants.*; import java.util.List; +import java.util.Collection; public class SimpleActionGrammar extends ActionGrammar { + private static String[][] REQUIRED_ATTRS = + { + { NAME_ATTR }, + { PATH_ATTR, TILES_DEFINITION_ATTR, RETURN_ACTION_ATTR, NAVIGATE_TO_ATTR, FORWARD_REF_ATTR } + }; + private static String[][] MUTUALLY_EXCLUSIVE_ATTRS = { - { REDIRECT_ATTR, EXTERNAL_REDIRECT_ATTR } + { PATH_ATTR, TILES_DEFINITION_ATTR, RETURN_ACTION_ATTR, NAVIGATE_TO_ATTR, FORWARD_REF_ATTR }, + { FORWARD_REF_ATTR, OUTPUT_FORM_BEAN_TYPE_ATTR, OUTPUT_FORM_BEAN_ATTR }, + { FORWARD_REF_ATTR, REDIRECT_ATTR, EXTERNAL_REDIRECT_ATTR }, + { FORWARD_REF_ATTR, ACTION_OUTPUTS_ATTR } }; + private ForwardGrammar _forwardGrammar; @@ -49,13 +62,14 @@ { super( env, diags, rvc, fcInfo ); + addMemberType( FORWARD_REF_ATTR, new ForwardRefType() ); addMemberArrayGrammar( CONDITIONAL_FORWARDS_ATTR, new SimpleActionForwardGrammar( env, diags, null, rvc, fcInfo ) ); // // The rest of the attributes are checked by ForwardGrammar. // - _forwardGrammar = new ForwardGrammar( env, diags, null, rvc, fcInfo ); + _forwardGrammar = new SimpleActionGrammarPart2(); } protected boolean onBeginCheck( AnnotationMirror annotation, AnnotationMirror[] parentAnnotations, @@ -78,16 +92,6 @@ return true; } - public String[][] getMutuallyExclusiveAttrs() - { - return MUTUALLY_EXCLUSIVE_ATTRS; - } - - public String[][] getRequiredAttrs() - { - return null; - } - private static class SimpleActionForwardGrammar extends ForwardGrammar { @@ -120,6 +124,50 @@ { super( CONDITIONAL_FORWARDS_ATTR ); } + } + } + + private class ForwardRefType + extends AnnotationMemberType + { + public ForwardRefType() + { + super( null, SimpleActionGrammar.this ); + } + + public Object onCheck( AnnotationTypeElementDeclaration valueDecl, AnnotationValue member, + AnnotationMirror[] parentAnnotations, MemberDeclaration classMember ) + { + Collection< AnnotationMirror > forwards = + getFlowControllerInfo().getMergedControllerAnnotation().getForwards(); + String forwardName = ( String ) member.getValue(); + + for ( AnnotationMirror forwardAnn : forwards ) + { + if ( forwardName.equals( CompilerUtils.getString( forwardAnn, NAME_ATTR, true ) ) ) + { + return null; + } + } + + addError( member, "error.unresolvable-global-forward", forwardName ); + return null; + } + } + + private class SimpleActionGrammarPart2 + extends ForwardGrammar + { + public SimpleActionGrammarPart2() + { + super( SimpleActionGrammar.this.getEnv(), SimpleActionGrammar.this.getDiagnostics(), null, + SimpleActionGrammar.this.getRuntimeVersionChecker(), + SimpleActionGrammar.this.getFlowControllerInfo() ); + } + + public String[][] getRequiredAttrs() + { + return REQUIRED_ATTRS; } } } Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/ActionModel.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/ActionModel.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/ActionModel.java&r1=125602&p2=incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/ActionModel.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/ActionModel.java (original) +++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/ActionModel.java Wed Jan 19 02:05:34 2005 @@ -73,6 +73,7 @@ private String _formClass; // applicable for non-ActionForm-derived types private Map< String, String > _conditionalForwards; private String _formBeanMessageResourcesKey; + private String _defaultForwardName; // for Simple Actions public ActionModel( String path, StrutsApp parent ) @@ -123,6 +124,7 @@ _isOverloaded = src._isOverloaded; _readonly = src._readonly; _unqualifiedActionPath = src._unqualifiedActionPath; + _defaultForwardName = src._defaultForwardName; } public void setFormBeanName( String formBeanName ) @@ -230,6 +232,7 @@ if ( _isOverloaded ) addSetProperty( xb, "overloaded", _isOverloaded ); if ( _readonly ) addSetProperty( xb, "readonly", _readonly ); if ( _isSimpleAction ) addSetProperty( xb, "simpleAction", _isSimpleAction ); + if ( _defaultForwardName != null ) addSetProperty( xb, "defaultForward", _defaultForwardName ); if ( _conditionalForwards != null ) { @@ -467,6 +470,16 @@ public void setUnqualifiedActionPath( String unqualifiedActionPath ) { this._unqualifiedActionPath = unqualifiedActionPath; + } + + public String getDefaultForwardName() + { + return _defaultForwardName; + } + + public void setDefaultForwardName( String defaultForwardName ) + { + _defaultForwardName = defaultForwardName; } public String getRoles() Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/AutoRegisterActionServlet.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/AutoRegisterActionServlet.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/AutoRegisterActionServlet.java&r1=125602&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/AutoRegisterActionServlet.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/AutoRegisterActionServlet.java (original) +++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/AutoRegisterActionServlet.java Wed Jan 19 02:05:34 2005 @@ -158,7 +158,7 @@ { try { - Class locatorClass = DiscoveryUtils.loadServiceClass( locatorClassName, ModuleConfigLocator.class ); + Class locatorClass = DiscoveryUtils.loadImplementorClass( locatorClassName, ModuleConfigLocator.class ); if ( locatorClass != null ) // previous call will log an error if it can't find the class { Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowController.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowController.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowController.java&r1=125602&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowController.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowController.java (original) +++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowController.java Wed Jan 19 02:05:34 2005 @@ -65,8 +65,13 @@ /** - * Base class for user-written flow controllers - PageFlowControllers and Global.app. + * Base class for user-written flow controllers - [EMAIL PROTECTED] PageFlowController}s and [EMAIL PROTECTED] SharedFlowController}s. */ [EMAIL PROTECTED]( + forwards={ + @Jpf.Forward(name="_auto", path="") + } +) public abstract class FlowController extends PageFlowManagedObject implements PageFlowConstants, ActionResolver { @@ -77,7 +82,6 @@ private static final int DEFAULT_MAX_CONCURRENT_REQUEST_COUNT = 4; private static final String MAX_CONCURRENT_REQUESTS_PARAM = "pageflow-max-concurrent-requests"; private static final int EXCEEDED_MAX_CONCURRENT_REQUESTS_ERRORCODE = 503; - private static final String DEFAULT_SIMPLE_ACTION_FORWARD_NAME = "_defaultForward"; private static final Locale DEFAULT_LOCALE = Locale.getDefault(); private static final ActionForward NULL_ACTION_FORWARD = new ActionForward(); private static final TokenProcessor TOKEN_PROCESSOR = TokenProcessor.getInstance(); @@ -491,10 +495,9 @@ } } - public synchronized void create( HttpServletRequest request, HttpServletResponse response, ServletContext servletContext ) + public synchronized void create( HttpServletRequest request, HttpServletResponse response, + ServletContext servletContext ) { - reinitialize( request, response, servletContext ); - PerRequestState prevState = setPerRequestState( new PerRequestState( request, response, null ) ); try @@ -514,7 +517,7 @@ } catch ( Exception e ) { - _log.error( "Exception thrown while handling exception in onCreate()", e ); + _log.error( "Exception thrown while handling exception in onCreate(): " + e.getMessage(), th ); } } } @@ -569,7 +572,6 @@ { } - /** * Callback that is invoked when this controller instance is "destroyed", i.e., removed from the * user session. [EMAIL PROTECTED] FlowController#getRequest}, [EMAIL PROTECTED] FlowController#getResponse}, and [EMAIL PROTECTED] FlowController#getActionMapping} may <i>not</i> @@ -1453,13 +1455,16 @@ } + String defaultForwardName = mapping.getDefaultForward(); + assert defaultForwardName != null : "defaultForwardName is null on Simple Action " + mapping.getPath(); + if ( _log.isTraceEnabled() ) { _log.trace( "No expression evaluated to true on simple action " + mapping.getPath() - + "; using forward " + DEFAULT_SIMPLE_ACTION_FORWARD_NAME + '.' ); + + "; using forward " + defaultForwardName + '.' ); } - return new Forward( DEFAULT_SIMPLE_ACTION_FORWARD_NAME ); + return new Forward( defaultForwardName ); } /** Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ForwardHandler.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ForwardHandler.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ForwardHandler.java&r1=125602&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ForwardHandler.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ForwardHandler.java (original) +++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ForwardHandler.java Wed Jan 19 02:05:34 2005 @@ -32,7 +32,11 @@ import org.apache.beehive.netui.pageflow.internal.InternalUtils; import org.apache.beehive.netui.pageflow.internal.RequestValues; import org.apache.beehive.netui.pageflow.internal.InternalConstants; +import org.apache.beehive.netui.pageflow.internal.ViewRenderer; import org.apache.beehive.netui.util.logging.Logger; +import org.apache.beehive.netui.script.common.ImplicitObjectUtil; + +import java.io.IOException; class ForwardHandler @@ -60,6 +64,11 @@ boolean isSpecialForward = false; boolean isReturnToCurrentPage = false; + if ( fwd != null && "_auto".equals( fwd.getName() ) ) // TODO: rename _auto + { + return doAutoViewRender( mapping, request, response, servletContext, flowController, form ); + } + if ( fwd != null && fwd instanceof Forward ) { Forward pageFlowFwd = ( Forward ) fwd; @@ -143,7 +152,7 @@ if ( pageFlowFwd.shouldPopPageFlow() ) { isSpecialForward = true; - fwd = doNestingReturn( pageFlowFwd, request, response, mapping ); + fwd = doNestingReturn( pageFlowFwd, request, response, mapping, flowController, form ); } // @@ -154,9 +163,9 @@ InternalUtils.addActionOutputs( pageFlowFwd.getActionOutputs() , request, true ); } - if ( _log.isDebugEnabled() ) + if ( fwd != null ) { - if ( fwd != null ) + if ( _log.isDebugEnabled() ) { if ( fwd.getRedirect() ) { @@ -167,10 +176,10 @@ _log.debug( "Forwarding to " + fwd.getPath() ); } } - else - { - _log.debug( "null ActionForward -- not doing any forward or redirect." ); - } + } + else + { + _log.debug( "null ActionForward -- not doing any forward or redirect." ); } // @@ -186,6 +195,42 @@ return fwd; } + private static ActionForward doAutoViewRender( ActionMapping mapping, HttpServletRequest request, + HttpServletResponse response, ServletContext servletContext, + FlowController flowController, ActionForm form ) + { + ViewRenderer vr = RequestValues.getViewRenderer( request ); + + if ( vr != null ) + { + _log.debug( "null ActionForward -- delegating to ViewRenderer " + vr + " to handle response." ); + + try + { + vr.renderView( request, response, servletContext ); + } + catch ( Throwable th ) + { + try + { + return flowController.handleException( th, mapping, form, request, response ); + } + catch ( Exception e ) + { + _log.error( "Exception thrown while handling exception in ViewRenderer " + vr + ": " + + e.getMessage(), th ); + } + } + + } + else + { + _log.debug( "No ViewRenderer -- not doing any forward or redirect." ); + } + + return null; + } + /** * Get an ActionForward to the original page that was visible before the previous action. */ @@ -376,7 +421,8 @@ } private static ActionForward doNestingReturn( Forward pageFlowFwd, HttpServletRequest request, - HttpServletResponse response, ActionMapping mapping ) + HttpServletResponse response, ActionMapping mapping, + FlowController flowController, ActionForm form ) { PageFlowStack pfStack = PageFlowStack.get( request ); String returnAction = pageFlowFwd.getPath(); @@ -403,6 +449,12 @@ InternalUtils.throwPageFlowException( ex, request ); } + // Only nested PageFlowControllers can have return actions. + assert flowController instanceof PageFlowController : flowController.getClass().getName(); + ActionForward exceptionFwd = + ( ( PageFlowController ) flowController ).exitNesting( request, response, mapping, form ); + if ( exceptionFwd != null ) return exceptionFwd; + PageFlowStack.PushedPageFlow pushedPageFlowWrapper = pfStack.pop( request ); PageFlowController poppedPageFlow = pushedPageFlowWrapper.getPageFlow(); @@ -465,7 +517,11 @@ // Store the returned form in the request. // ActionForm retForm = pageFlowFwd.getFirstOutputForm( request ); - if ( retForm != null ) RequestValues.setForwardedForm( request, retForm ); + if ( retForm != null ) + { + RequestValues.setForwardedFormBean( request, retForm ); + ImplicitObjectUtil.loadOutputFormBean( request, InternalUtils.unwrapFormBean( retForm ) ); + } // TODO: delete this deprecated feature (following line). This is the Jpf.NavigateTo.page value. request.setAttribute( InternalConstants.RETURNING_FROM_NESTING_ATTR, Boolean.TRUE ); Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowController.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowController.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowController.java&r1=125602&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowController.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowController.java (original) +++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowController.java Wed Jan 19 02:05:34 2005 @@ -21,6 +21,8 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSessionBindingEvent; import javax.servlet.ServletContext; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; import java.lang.reflect.Field; import java.util.Map; @@ -31,6 +33,7 @@ import org.apache.struts.config.ControllerConfig; import org.apache.beehive.netui.util.logging.Logger; import org.apache.beehive.netui.util.FileUtils; +import org.apache.beehive.netui.util.DiscoveryUtils; import org.apache.beehive.netui.util.cache.ClassLevelCache; import org.apache.beehive.netui.pageflow.config.PageFlowControllerConfig; import org.apache.beehive.netui.pageflow.internal.CachedPageFlowInfo; @@ -38,6 +41,8 @@ import org.apache.beehive.netui.pageflow.internal.InternalConstants; import org.apache.beehive.netui.pageflow.internal.ServerAdapterManager; import org.apache.beehive.netui.pageflow.internal.CachedSharedFlowRefInfo; +import org.apache.beehive.netui.pageflow.internal.ViewRenderer; +import org.apache.beehive.netui.pageflow.internal.RequestValues; import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils; import org.apache.beehive.netui.pageflow.annotations.Jpf; @@ -83,6 +88,7 @@ private PreviousActionInfo _previousActionInfo; private boolean _isOnNestingStack = false; + private ViewRenderer _returnActionViewRenderer = null; private static final String DELETING_PAGEFLOW_ATTR = InternalConstants.ATTR_PREFIX + "deletingPageFlow"; private static final String CACHED_INFO_KEY = "cachedInfo"; @@ -282,10 +288,31 @@ } public final synchronized void create( HttpServletRequest request, HttpServletResponse response, - ServletContext servletContext ) + ServletContext servletContext ) { reinitialize( request, response, servletContext ); initializeSharedFlowFields( request ); + + if ( isNestable() ) + { + // + // Initialize a ViewRenderer for exiting the nested page flow. + // + String vrClassName = request.getParameter( InternalConstants.RETURN_ACTION_VIEW_RENDERER_PARAM ); + + if ( vrClassName != null ) + { + ViewRenderer vr = + ( ViewRenderer ) DiscoveryUtils.newImplementorInstance( vrClassName, ViewRenderer.class ); + + if ( vr != null ) + { + vr.init( request ); + _returnActionViewRenderer = vr; + } + } + } + super.create( request, response, servletContext ); } @@ -845,5 +872,48 @@ savePreviousPageInfo( actionForward, null, null, request, getServletContext(), false ); } } + } + + ActionForward exitNesting( HttpServletRequest request, HttpServletResponse response, ActionMapping mapping, + ActionForm form ) + { + if ( _returnActionViewRenderer != null ) + { + RequestValues.setViewRenderer( request, _returnActionViewRenderer ); + } + + PerRequestState prevState = setPerRequestState( new PerRequestState( request, response, mapping ) ); + + try + { + onExitNesting(); + } + catch ( Throwable th ) + { + try + { + return handleException( th, mapping, form, request, response ); + } + catch ( Exception e ) + { + _log.error( "Exception thrown while handling exception in onExitNesting()", e ); + } + } + finally + { + setPerRequestState( prevState ); + } + + return null; + } + + /** + * Callback that is invoked when this controller instance is exiting nesting (through a return action). + * [EMAIL PROTECTED] FlowController#getRequest}, [EMAIL PROTECTED] FlowController#getResponse}, [EMAIL PROTECTED] FlowController#getSession} + * may all be used during this method. + */ + protected void onExitNesting() + throws Exception + { } } Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java&r1=125602&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java (original) +++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java Wed Jan 19 02:05:34 2005 @@ -367,7 +367,7 @@ // if ( mapping != null ) setOutputForms( mapping, fwd.getOutputForms(), request, overwrite ); - RequestValues.setForwardedForm( request, fwd.getFirstOutputForm( request ) ); + RequestValues.setForwardedFormBean( request, fwd.getFirstOutputForm( request ) ); } /** @@ -391,7 +391,7 @@ setOutputForms( mapping, fwd.getOutputForms(), request ); } - RequestValues.setForwardedForm( request, fwd.getFirstOutputForm( request ) ); + RequestValues.setForwardedFormBean( request, fwd.getFirstOutputForm( request ) ); } /** Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/annotations/Jpf.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/annotations/Jpf.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/annotations/Jpf.java&r1=125602&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/annotations/Jpf.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/annotations/Jpf.java (original) +++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/annotations/Jpf.java Wed Jan 19 02:05:34 2005 @@ -297,27 +297,33 @@ boolean doValidation() default false; /** - * The forward path. Mutually-exclusive with <code>tilesDefinition</code>, + * The forward path. Mutually-exclusive with <code>tilesDefinition</code>, <code>forwardRef</code>, * <code>returnAction</code> and <code>navigateTo</code>. */ String path() default ""; + + /** + * The name of a class-level forward ([EMAIL PROTECTED] Forward}). Mutually-exclusive with with <code>path</code>, + * <code>tilesDefinition</code>, <code>returnAction</code> and <code>navigateTo</code>. + */ + String forwardRef() default ""; /** - * The Tiles definition to forward to. Mutually-exclusive with <code>path</code>, + * The Tiles definition to forward to. Mutually-exclusive with <code>path</code>, <code>forwardRef</code>, * <code>returnAction</code> and <code>navigateTo</code>. */ String tilesDefinition() default ""; /** * The action to be invoked on the calling page flow. Mutually-exclusive with <code>path</code>, - * <code>tilesDefinition</code> and <code>navigateTo</code>, and only valid in a nested page flow - * (<code>nested</code> on the <code>Controller</code> annotation must be true). + * <code>forwardRef</code>, <code>tilesDefinition</code> and <code>navigateTo</code>, and only valid in a + * nested page flow (<code>nested</code> on the <code>Controller</code> annotation must be true). */ String returnAction() default ""; /** * A symbolic name for the page/action to which to navigate. Mutually-exclusive with - * <code>path</code>, <code>tilesDefinition</code> and <code>returnAction</code> + * <code>path</code>, <code>forwardRef</code>, <code>tilesDefinition</code> and <code>returnAction</code> */ NavigateTo navigateTo() default NavigateTo.currentPage; Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/config/PageFlowActionMapping.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/config/PageFlowActionMapping.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/config/PageFlowActionMapping.java&r1=125602&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/config/PageFlowActionMapping.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/config/PageFlowActionMapping.java (original) +++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/config/PageFlowActionMapping.java Wed Jan 19 02:05:34 2005 @@ -39,6 +39,7 @@ private boolean _readonly = false; private Map< String, String > _conditionalForwards = new LinkedHashMap< String, String >(); private String _formBeanMessageResourcesKey; + private String _defaultForward; public String getUnqualifiedActionPath() @@ -164,5 +165,15 @@ public void setFormBeanMessageResourcesKey( String formBeanMessageResourcesKey ) { _formBeanMessageResourcesKey = formBeanMessageResourcesKey; + } + + public String getDefaultForward() + { + return _defaultForward; + } + + public void setDefaultForward( String defaultForward ) + { + _defaultForward = defaultForward; } } Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/BackingClassMethodBinding.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/BackingClassMethodBinding.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/BackingClassMethodBinding.java&r1=125602&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/BackingClassMethodBinding.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/BackingClassMethodBinding.java (original) +++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/BackingClassMethodBinding.java Wed Jan 19 02:05:34 2005 @@ -108,7 +108,7 @@ Field field = backingClass.getDeclaredField( formBeanMember ); field.setAccessible( true ); Object value = field.get( backingBean ); - RequestValues.setForwardedForm( httpRequest, InternalUtils.wrapFormBean( value ) ); + RequestValues.setForwardedFormBean( httpRequest, InternalUtils.wrapFormBean( value ) ); } catch ( NoSuchFieldException e ) { Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowActionListener.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowActionListener.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowActionListener.java&r1=125602&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowActionListener.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowActionListener.java (original) +++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowActionListener.java Wed Jan 19 02:05:34 2005 @@ -53,7 +53,7 @@ if ( request instanceof ServletRequest ) { ActionForm wrappedFormBean = InternalUtils.wrapFormBean( beanInstance ); - RequestValues.setForwardedForm( ( ServletRequest ) request, wrappedFormBean ); + RequestValues.setForwardedFormBean( ( ServletRequest ) request, wrappedFormBean ); } } Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalConstants.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalConstants.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalConstants.java&r1=125602&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalConstants.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalConstants.java (original) +++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalConstants.java Wed Jan 19 02:05:34 2005 @@ -58,4 +58,5 @@ public static final String NETUI_CONFIG_PATH = "/WEB-INF/netui-config.xml"; + public static final String RETURN_ACTION_VIEW_RENDERER_PARAM = ATTR_PREFIX + "returnActionViewRenderer"; } Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/RequestValues.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/RequestValues.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/RequestValues.java&r1=125602&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/RequestValues.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/RequestValues.java (original) +++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/RequestValues.java Wed Jan 19 02:05:34 2005 @@ -35,6 +35,7 @@ private static final String ORIGINAL_SERVLET_PATH_ATTR = ATTR_PREFIX + "origServletPath"; private static final String FORWARDED_FORMBEAN_ATTR = ATTR_PREFIX + "forwardedForm"; private static final String CURRENT_FLOWCONTROLLER_ATTR = ATTR_PREFIX + "flowController"; + private static final String VIEW_RENDERER_ATTR = ATTR_PREFIX + "viewRenderer"; public static boolean isForwardedRequest( ServletRequest request ) @@ -86,7 +87,7 @@ * Set the forwarded form. This overrides the auto-generated form created by processActionForm * and populated by processPopulate (in PageFlowRequestProcessor). */ - public static void setForwardedForm( ServletRequest request, ActionForm form ) + public static void setForwardedFormBean( ServletRequest request, ActionForm form ) { if ( form == null ) { @@ -118,5 +119,15 @@ public static void removeCurrentFlowController( ServletRequest request ) { request.removeAttribute( CURRENT_FLOWCONTROLLER_ATTR ); + } + + public static ViewRenderer getViewRenderer( ServletRequest request ) + { + return ( ViewRenderer ) request.getAttribute( VIEW_RENDERER_ATTR ); + } + + public static void setViewRenderer( ServletRequest request, ViewRenderer viewRenderer ) + { + request.setAttribute( VIEW_RENDERER_ATTR, viewRenderer ); } } Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ServerAdapterManager.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ServerAdapterManager.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ServerAdapterManager.java&r1=125602&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ServerAdapterManager.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ServerAdapterManager.java (original) +++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ServerAdapterManager.java Wed Jan 19 02:05:34 2005 @@ -113,7 +113,7 @@ if ( serverAdapterClassName != null ) { - Class serverAdapterClass = DiscoveryUtils.loadServiceClass( serverAdapterClassName, ServerAdapter.class ); + Class serverAdapterClass = DiscoveryUtils.loadImplementorClass( serverAdapterClassName, ServerAdapter.class ); if ( serverAdapterClass != null ) { @@ -125,7 +125,7 @@ } } - Class[] classes = DiscoveryUtils.getServiceClasses( ServerAdapter.class ); + Class[] classes = DiscoveryUtils.getImplementorClasses( ServerAdapter.class ); for ( int i = 0; i < classes.length; i++ ) { Added: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ViewRenderer.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ViewRenderer.java?view=auto&rev=125603 ============================================================================== --- (empty file) +++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ViewRenderer.java Wed Jan 19 02:05:34 2005 @@ -0,0 +1,30 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * $Header:$ + */ +package org.apache.beehive.netui.pageflow.internal; + +import javax.servlet.ServletResponse; +import javax.servlet.ServletRequest; +import javax.servlet.ServletContext; +import java.io.IOException; + +public interface ViewRenderer +{ + public void init( ServletRequest request ); + public void renderView( ServletRequest servletRequest, ServletResponse response, ServletContext servletContext ) + throws IOException; +} Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/script/common/ImplicitObjectUtil.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/script/common/ImplicitObjectUtil.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/script/common/ImplicitObjectUtil.java&r1=125602&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/script/common/ImplicitObjectUtil.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/script/common/ImplicitObjectUtil.java (original) +++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/script/common/ImplicitObjectUtil.java Wed Jan 19 02:05:34 2005 @@ -59,6 +59,7 @@ private static final String BACKING_IMPLICIT_OBJECT_KEY = "backing"; private static final String PAGE_INPUT_IMPLICIT_OBJECT_KEY = "pageInput"; private static final String ACTION_FORM_IMPLICIT_OBJECT_KEY = "actionForm"; + private static final String OUTPUT_FORM_BEAN_OBJECT_KEY = "outputFormBean"; private ImplicitObjectUtil() {} @@ -71,7 +72,7 @@ { jspContext.removeAttribute(ACTION_FORM_IMPLICIT_OBJECT_KEY); } - + public static final void loadPageFlow(ServletRequest request, PageFlowController pageFlow, FacesBackingBean fbb) { if(pageFlow == null) @@ -300,5 +301,11 @@ // @todo: need to move bundleMap creation to a BundleMapFactory BundleMap bundleMap = new BundleMap( request, servletContext, null ); loadBundleMap( request, bundleMap ); + } + + public static final void loadOutputFormBean(ServletRequest request, Object bean) + { + if (bean != null) + request.setAttribute(OUTPUT_FORM_BEAN_OBJECT_KEY, bean); } } Modified: incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/invoke/CallPageFlow.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/invoke/CallPageFlow.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/invoke/CallPageFlow.java&r1=125602&p2=incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/invoke/CallPageFlow.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/invoke/CallPageFlow.java (original) +++ incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/invoke/CallPageFlow.java Wed Jan 19 02:05:34 2005 @@ -22,7 +22,6 @@ import javax.servlet.http.HttpServletResponse; // internal imports -import org.apache.beehive.netui.pageflow.PageFlowController; import org.apache.beehive.netui.pageflow.PageFlowUtils; import org.apache.beehive.netui.pageflow.internal.InternalUtils; @@ -138,7 +137,9 @@ { try { - PageFlowController jpf = PageFlowUtils.getCurrentPageFlow((HttpServletRequest)pageContext.getRequest()); + // TODO: because of a javac bug (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5090006), we + // can't call PageFlowUtils.getCurrentPageFlow here; thus, the call to getCurrentActionResolver. + Object jpf = PageFlowUtils.getCurrentActionResolver((HttpServletRequest)pageContext.getRequest()); if(_logger.isDebugEnabled()) _logger.debug("Found a pageflow of type: " + (jpf != null ? jpf.getClass().getName() : "null")); Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractClassicTag.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractClassicTag.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractClassicTag.java&r1=125602&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractClassicTag.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractClassicTag.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractClassicTag.java Wed Jan 19 02:05:34 2005 @@ -23,6 +23,7 @@ import org.apache.beehive.netui.tags.naming.FormDataNameInterceptor; import org.apache.beehive.netui.tags.naming.IndexedNameInterceptor; import org.apache.beehive.netui.tags.naming.INameInterceptor; +import org.apache.beehive.netui.tags.internal.IIdProvider; import org.apache.beehive.netui.util.Bundle; import org.apache.beehive.netui.util.logging.Logger; import org.apache.struts.Globals; @@ -35,6 +36,7 @@ import javax.servlet.jsp.tagext.BodyTagSupport; import javax.servlet.jsp.tagext.SimpleTagSupport; import javax.servlet.jsp.tagext.Tag; +import javax.servlet.ServletRequest; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; @@ -62,7 +64,7 @@ * @netui:tag */ public abstract class AbstractClassicTag - extends BodyTagSupport implements INetuiTag + extends BodyTagSupport implements INetuiTag, IIdProvider { //@todo: how should we handle errors messages from third party tags? //@todo: need to implement the flag to turn errors into JSP exceptions @@ -482,7 +484,7 @@ * @param req the Request * @return the next unique integer for this request. */ - protected int getNextId(HttpServletRequest req) + public int getNextId(ServletRequest req) { Integer i = (Integer) req.getAttribute(NETUI_UNIQUE_CNT); if (i == null) { Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/AnchorBase.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/AnchorBase.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/AnchorBase.java&r1=125602&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/AnchorBase.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/AnchorBase.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/AnchorBase.java Wed Jan 19 02:05:34 2005 @@ -2,10 +2,12 @@ import org.apache.beehive.netui.core.urls.MutableURI; import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils; +import org.apache.beehive.netui.pageflow.internal.InternalConstants; import org.apache.beehive.netui.tags.ByRef; import org.apache.beehive.netui.tags.HtmlUtils; import org.apache.beehive.netui.tags.IScriptReporter; import org.apache.beehive.netui.tags.internal.PageFlowTagUtils; +import org.apache.beehive.netui.tags.internal.ReturnActionViewRenderer; import org.apache.beehive.netui.tags.rendering.*; import org.apache.beehive.netui.util.Bundle; import org.apache.beehive.netui.util.ParamHelper; @@ -26,7 +28,7 @@ * This may not be the best OO design, but the design is optimized for performance of rendering anchor elements. */ abstract public class AnchorBase extends HtmlBaseTag - implements IUrlParams + implements IUrlParams, IHasPopupSupport { private static final String REQUIRED_ATTR = "href, action, linkName, clientAction"; private static final Logger logger = Logger.getInstance(AnchorBase.class); @@ -37,11 +39,12 @@ private String _action; private String _href; - private String _targetScope; // target page flow scope; see comments on setTargetScope() - private String _location; // anchor to be added to the end of the hyperlink. - private Map _params; // Parameters - private Form _form; // the nearest form - private boolean _formSubmit = false; // should the anchor submit an enclosing form? + private String _targetScope; // target page flow scope; see comments on setTargetScope() + private String _location; // anchor to be added to the end of the hyperlink. + private Map _params; // Parameters + private Form _form; // the nearest form + private boolean _formSubmit = false; // should the anchor submit an enclosing form? + private PopupHelper _popupHelper = null; // popup support, if the popup attribute is set to true /** * Base support for the attribute tag. This is overridden to prevent setting the <code>href</code> @@ -176,6 +179,22 @@ { _formSubmit = formSubmit; } + + /** + * Sets the popup indicator. + * @param popup - whether or not the anchor should open a popup window. + * @jsptagref.attributedescription Boolean. If <code>popup</code> is set to true, + * the anchor will open a popup window. + * @jsptagref.databindable true + * @jsptagref.attributesyntaxvalue <i>boolean_popup</i> + * @netui:attribute required="false" rtexprvalue="true" type="boolean" + * description="If popup is set to true, the anchor will open a popup window. + * @netui.tldx:attribute + */ + public void setPopup(boolean popup) + { + _popupHelper = new PopupHelper(); + } /** @@ -269,7 +288,7 @@ } ParamHelper.addParam(_params, name, value); } - + /** * This method will create the <a> portion of an anchor. It is called by subclasses, for example, the * <code>ImageAnchor</code> relies on this code to generate the <a>. @@ -346,10 +365,7 @@ // String token = PageFlowTagUtils.getToken(request, _action); if (token != null) { - if (_params == null) { - _params = new HashMap(); - } - _params.put(Constants.TOKEN_KEY, token); + addParamInternal(Constants.TOKEN_KEY, token); } } } @@ -368,12 +384,13 @@ else { // Add the scope-ID parameter, if the targetScope attribute is present. if (_targetScope != null) { - if (_params == null) { - _params = new HashMap(); - } - _params.put(ScopedServletUtils.SCOPE_ID_PARAM, _targetScope); + addParamInternal(ScopedServletUtils.SCOPE_ID_PARAM, _targetScope); } + if (_popupHelper != null) { + _popupHelper.addParams(this, this, request); + } + // Generate the opening anchor element MutableURI uri = null; try { @@ -431,11 +448,16 @@ } // if the user override the onclick we will ignore this - if (_state.onClick == null && _formSubmit && formAction != null) { - String realFormName = getFormId(); - _state.onClick = jsu.writeAnchorFormSubmitAction(realFormName, _state.href); - if (_form != null) - _form.insureRealId(); + if (_state.onClick == null) { + if (_formSubmit && formAction != null) { + String realFormName = getFormId(); + _state.onClick = jsu.writeAnchorFormSubmitAction(realFormName, _state.href); + if (_form != null) + _form.insureRealId(); + } + else if (_popupHelper != null) { + _state.onClick = _popupHelper.getOnClick(_state.href); + } } if (hasErrors()) @@ -444,12 +466,14 @@ trb.doStartTag(writer, _state); //Emit javascript if this anchor needs to sumbit the form - if (_formSubmit && formAction != null || idScript != null) { + if (_formSubmit && formAction != null || idScript != null || _popupHelper != null) { StringBuilder script = new StringBuilder(32); StringBuilderRenderAppender scriptWriter = new StringBuilderRenderAppender(script); if (_formSubmit && formAction != null) jsu.writeAnchorFormSubmit(getScriptReporter(), scriptWriter); + if (_popupHelper != null) + _popupHelper.writeScript(jsu, getScriptReporter(), scriptWriter); if (idScript != null) scriptWriter.append(idScript); scriptRef.setRef(script.toString()); @@ -459,6 +483,14 @@ return true; } + private void addParamInternal(String paramName, String paramVal) + { + if (_params == null) { + _params = new HashMap(); + } + _params.put(paramName, paramVal); + } + /** * * @param req @@ -561,6 +593,11 @@ _params = null; _form = null; _formSubmit = false; + _popupHelper = null; } + public IPopupSupport getPopupSupport() + { + return _popupHelper; + } } Added: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ConfigurePopup.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ConfigurePopup.java?view=auto&rev=125603 ============================================================================== --- (empty file) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ConfigurePopup.java Wed Jan 19 02:05:34 2005 @@ -0,0 +1,327 @@ +/* +* Copyright 2004 The Apache Software Foundation. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* $Header:$ +*/ +package org.apache.beehive.netui.tags.html; + +import org.apache.beehive.netui.util.Bundle; +import org.apache.beehive.netui.tags.AbstractClassicTag; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.JspTag; +import javax.servlet.jsp.tagext.SimpleTagSupport; + + +/** + * Configures popup window parameters for parent tags that can open popup windows. + * @jsptagref.tagdescription Configures popup window parameters for parent tags that can open popup windows. + * @example + * + * <pre> + * <netui:anchor action="getZip"> + * Look up a zip code + * <netui:configurePopup resizable="false" width="400" height="200"> + * Search Google with the query "Socrates" + * <netui:retrievePopupOutput fieldId="zipCodeField" expressionToRetrieve="outputFormBean.zipCode" /> + * </netui:configurePopup> + * </netui:anchor></pre> + * @netui:tag name="configurePopup" description="Configures popup window parameters for parent tags that can open popup windows." + * @netui.tldx:tag requiredparent="anchor button form image imageAnchor data:anchorColumn" + * requiredchild="#nothing" + * renderer="TODO" + * bodycontentpref="empty" + * whitespace="indent" + */ +public class ConfigurePopup + extends AbstractClassicTag +{ + private String _name = ""; + private Boolean _toolbar = null; + private Boolean _location = null; + private Boolean _directories = null; + private Boolean _status = null; + private Boolean _menubar = null; + private Boolean _resizable = null; + private Boolean _scrollbars = null; + private Integer _width = null; + private Integer _height = null; + private Integer _left = null; + private Integer _top = null; + private boolean _replace = false; + private String _onPopupDone; + + /** + * Return the name of the Tag. + */ + public String getTagName() + { + return "ConfigurePopup"; + } + + /** + * Sets the JavaScript function to be called when the popup window is closing. If this attribute is not present, + * a default function will be generated. + * @param onPopupDone - the JavaScript function to be called when the popup window is closing. + * @jsptagref.attributedescription The JavaScript function to be called when the popup window is closing. + * @jsptagref.databindable false + * @jsptagref.attributesyntaxvalue <i>string_onPopupDone</i> + * @netui:attribute required="false" rtexprvalue="true" + * description="The JavaScript function to be called when the popup window is closing." + */ + public void setOnPopupDone(String onPopupDone) + { + _onPopupDone = onPopupDone; + } + + /** + * Sets the name of the popup window. + * @param name - the name of the popup window. + * @jsptagref.attributedescription The name of the popup window. + * @jsptagref.databindable true + * @jsptagref.attributesyntaxvalue <i>string_name</i> + * @netui:attribute required="false" rtexprvalue="true" + * description="The name of the popup window." + */ + public void setName(String name) + { + _name = name; + } + + /** + * Sets whether the toolbar is visible in the popup window. + * @param toolbar - whether the toolbar is visible in the popup window. + * @jsptagref.attributedescription Whether the toolbar is visible in the popup window. + * @jsptagref.databindable true + * @jsptagref.attributesyntaxvalue <i>boolean_toolbar</i> + * @netui:attribute required="false" rtexprvalue="true" + * description="Whether the toolbar is visible in the popup window." + */ + public void setToolbar(boolean toolbar) + { + _toolbar = toolbar; + } + + /** + * Sets whether the location (address) bar is visible in the popup window. + * @param location - whether the location (address) bar is visible in the popup window. + * @jsptagref.attributedescription Whether the location (address) bar is visible in the popup window. + * @jsptagref.databindable true + * @jsptagref.attributesyntaxvalue <i>boolean_location</i> + * @netui:attribute required="false" rtexprvalue="true" + * description="Whether the location (address) bar is visible in the popup window." + */ + public void setLocation(boolean location) + { + _location = location; + } + + /** + * Sets whether directory buttons are displayed in the popup window. + * @param directories - whether directory buttons are displayed in the popup window. + * @jsptagref.attributedescription Whether directory buttons are displayed in the popup window. + * @jsptagref.databindable true + * @jsptagref.attributesyntaxvalue <i>boolean_directories</i> + * @netui:attribute required="false" rtexprvalue="true" + * description="Whether directory buttons are displayed in the popup window." + */ + public void setDirectories(boolean directories) + { + _directories = directories; + } + + /** + * Sets whether the status bar is displayed in the popup window. + * @param status - whether the status bar is displayed in the popup window. + * @jsptagref.attributedescription Whether the status bar is displayed in the popup window. + * @jsptagref.databindable true + * @jsptagref.attributesyntaxvalue <i>boolean_status</i> + * @netui:attribute required="false" rtexprvalue="true" + * description="Whether the status bar is displayed in the popup window." + */ + public void setStatus(boolean status) + { + _status = status; + } + + /** + * Sets whether the menu bar is displayed in the popup window. + * @param menubar - whether the menu bar is displayed in the popup window. + * @jsptagref.attributedescription Whether the menu bar is displayed in the popup window. + * @jsptagref.databindable true + * @jsptagref.attributesyntaxvalue <i>boolean_menubar</i> + * @netui:attribute required="false" rtexprvalue="true" + * description="Whether the menu bar is displayed in the popup window." + */ + public void setMenubar(boolean menubar) + { + _menubar = menubar; + } + + /** + * Sets whether the popup window has scroll bars. + * @param scrollbars - whether the popup window has scroll bars. + * @jsptagref.attributedescription Whether the popup window has scroll bars. + * @jsptagref.databindable true + * @jsptagref.attributesyntaxvalue <i>boolean_scrollbars</i> + * @netui:attribute required="false" rtexprvalue="true" + * description="Whether the popup window has scroll bars." + */ + public void setScrollbars(boolean scrollbars) + { + _scrollbars = scrollbars; + } + + /** + * Sets whether the popup window is resizable. + * @param resizable - whether the popup window is resizable. + * @jsptagref.attributedescription Whether the popup window is resizable. + * @jsptagref.databindable true + * @jsptagref.attributesyntaxvalue <i>boolean_resizable</i> + * @netui:attribute required="false" rtexprvalue="true" + * description="Whether the popup window is resizable." + */ + public void setResizable(boolean resizable) + { + _resizable = resizable; + } + + /** + * Sets the width of the popup window. + * @param width - the width of the popup window. + * @jsptagref.attributedescription The width of the popup window. + * @jsptagref.databindable true + * @jsptagref.attributesyntaxvalue <i>integer_width</i> + * @netui:attribute required="false" rtexprvalue="true" + * description="The width of the popup window." + */ + public void setWidth(int width) + { + _width = width; + } + + /** + * Sets the height of the popup window. + * @param height - the height of the popup window. + * @jsptagref.attributedescription The height of the popup window. + * @jsptagref.databindable true + * @jsptagref.attributesyntaxvalue <i>integer_height</i> + * @netui:attribute required="false" rtexprvalue="true" + * description="The height of the popup window." + */ + public void setHeight(int height) + { + _height = height; + } + + /** + * Sets the X coordinate of the top left corner of the popup window. + * @param left - the X coordinate of the top left corner of the popup window. + * @jsptagref.attributedescription The X coordinate of the top left corner of the popup window. + * @jsptagref.databindable true + * @jsptagref.attributesyntaxvalue <i>integer_left</i> + * @netui:attribute required="false" rtexprvalue="true" + * description="The X coordinate of the top left corner of the popup window." + */ + public void setLeft(int left) + { + _left = left; + } + + /** + * Sets the Y coordinate of the top left corner of the popup window. + * @param top - the Y coordinate of the top left corner of the popup window. + * @jsptagref.attributedescription The Y coordinate of the top left corner of the popup window. + * @jsptagref.databindable true + * @jsptagref.attributesyntaxvalue <i>integer_left</i> + * @netui:attribute required="false" rtexprvalue="true" + * description="The Y coordinate of the top left corner of the popup window." + */ + public void setTop(int top) + { + _top = top; + } + + /** + * Sets whether the popup window's location will replace the location in the current window's navigation history. + * @param replace - whether the popup window's location will replace the location in the current window's navigation history. + * @jsptagref.attributedescription Whether the popup window's location will replace the location in the current window's navigation history. + * @jsptagref.databindable true + * @jsptagref.attributesyntaxvalue <i>boolean_replace</i> + * @netui:attribute required="false" rtexprvalue="true" + * description="Whether the popup window's location will replace the location in the current window's navigation history." + */ + public void setReplace(boolean replace) + { + _replace = replace; + } + + /** + * @throws JspException if a JSP exception has occurred + */ + public int doStartTag() throws JspException + { + JspTag parentTag = SimpleTagSupport.findAncestorWithClass(this, IHasPopupSupport.class); + if (parentTag == null) { + String msg = Bundle.getString("Tags_InvalidConfigurePopupParent"); + registerTagError(msg, null); + reportErrors(); + } + else { + IPopupSupport popupSupport = ((IHasPopupSupport) parentTag).getPopupSupport(); + + // if popupSupport is null, then the tag isn't set to open a popup window + if (popupSupport != null) { + popupSupport.setName(_name); + if (_toolbar != null) + popupSupport.setToolbar(_toolbar); + if (_location != null) + popupSupport.setLocation(_location); + if (_directories != null) + popupSupport.setDirectories(_directories); + if (_status != null) + popupSupport.setStatus(_status); + if (_menubar != null) + popupSupport.setMenubar(_menubar); + if (_resizable != null) + popupSupport.setResizable(_resizable); + if (_scrollbars != null) + popupSupport.setScrollbars(_scrollbars); + if (_width != null) + popupSupport.setWidth(_width); + if (_height != null) + popupSupport.setHeight(_height); + if (_left != null) + popupSupport.setLeft(_left); + if (_top != null) + popupSupport.setTop(_top); + popupSupport.setReplace(_replace); + popupSupport.setOnPopupDone(_onPopupDone); + } + } + + localRelease(); + return EVAL_BODY_INCLUDE; + } + + /** + * Release any acquired resources. + */ + protected void localRelease() + { + super.localRelease(); + } + +} Added: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/IHasPopupSupport.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/IHasPopupSupport.java?view=auto&rev=125603 ============================================================================== --- (empty file) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/IHasPopupSupport.java Wed Jan 19 02:05:34 2005 @@ -0,0 +1,24 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * $Header:$ + */ +package org.apache.beehive.netui.tags.html; + +interface IHasPopupSupport +{ + public void setPopup(boolean popup); + public IPopupSupport getPopupSupport(); +} Added: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/IPopupSupport.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/IPopupSupport.java?view=auto&rev=125603 ============================================================================== --- (empty file) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/IPopupSupport.java Wed Jan 19 02:05:34 2005 @@ -0,0 +1,36 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * $Header:$ + */ +package org.apache.beehive.netui.tags.html; + +interface IPopupSupport +{ + public void setName(String name); + public void setToolbar(boolean toolbar); + public void setLocation(boolean location); + public void setDirectories(boolean directories); + public void setStatus(boolean status); + public void setMenubar(boolean menubar); + public void setScrollbars(boolean scrollbars); + public void setResizable(boolean resizable); + public void setWidth(int width); + public void setHeight(int height); + public void setLeft(int left); + public void setTop(int top); + public void setReplace(boolean replace); + public void setOnPopupDone(String onPopupDone); +} Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/JavaScriptUtils.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/JavaScriptUtils.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/JavaScriptUtils.java&r1=125602&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/JavaScriptUtils.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/JavaScriptUtils.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/JavaScriptUtils.java Wed Jan 19 02:05:34 2005 @@ -39,10 +39,11 @@ private static final int SCOPE_LOOKUP = 0x0008; private static final int ROLLOVER = 0x0010; private static final int ANCHOR_SUBMIT = 0x0020; - private static final int ALLOCATE_LEGACY = 0x0040; - private static final int ALLOCATE_ID = 0x0080; - private static final int ALLOCATE_NAME = 0x0100; - private static final int LEGACY_SCOPE_LOOKUP = 0x0200; + private static final int POPUP_FUNC = 0x0040; + private static final int ALLOCATE_LEGACY = 0x0080; + private static final int ALLOCATE_ID = 0x0100; + private static final int ALLOCATE_NAME = 0x0200; + private static final int LEGACY_SCOPE_LOOKUP = 0x0400; private static final String BUNDLE_NAME = "org.apache.beehive.netui.tags.html.javaScript"; @@ -67,7 +68,7 @@ String s = getString("anchorFormSubmit", null); // if we passed in a script reporter, it will handle the - // javaScript, otherwise update the buffer by writting a + // javaScript, otherwise update the buffer by writing a // script block into it. if (scriptReporter != null) { scriptReporter.addScriptFunction(s); @@ -86,13 +87,38 @@ { assert (action != null); assert (newAction != null); - + // @TODO: Need to escape the action? and newAction/ String s = getString("anchorFormSubmitAction", - new Object[]{action, newAction}); + new Object[]{action, newAction}); return s; } - + + /** + * @param scriptReporter + * @param results + */ + public void writePopupFunc(IScriptReporter scriptReporter, AbstractRenderAppender results) + { + // check to see if we have already written out the popup function + if ((_javaScriptFeatures & POPUP_FUNC) != 0) + return; + _javaScriptFeatures |= POPUP_FUNC; + + // get the method and write it. + String s = getString("popupFunc", null); + + // if we passed in a script reporter, it will handle the + // javaScript, otherwise update the buffer by writing a + // script block into it. + if (scriptReporter != null) { + scriptReporter.addScriptFunction(s); + return; + } + + writeScriptBlock(results, s); + } + /** * this will write out the form focus script block * @param formName Added: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/PopupHelper.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/PopupHelper.java?view=auto&rev=125603 ============================================================================== --- (empty file) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/PopupHelper.java Wed Jan 19 02:05:34 2005 @@ -0,0 +1,174 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * $Header:$ + */ +package org.apache.beehive.netui.tags.html; + +import org.apache.beehive.netui.pageflow.internal.InternalConstants; +import org.apache.beehive.netui.tags.internal.ReturnActionViewRenderer; +import org.apache.beehive.netui.tags.internal.IIdProvider; +import org.apache.beehive.netui.tags.IScriptReporter; +import org.apache.beehive.netui.tags.AbstractClassicTag; +import org.apache.beehive.netui.tags.rendering.AbstractRenderAppender; + +import javax.servlet.jsp.JspException; +import javax.servlet.ServletRequest; +import java.util.HashMap; +import java.util.Map; + +class PopupHelper + implements IPopupSupport +{ + private static final String VIEW_RENDERER_CLASS_NAME = ReturnActionViewRenderer.class.getName(); + private static final String ON_POPUP_DONE_FUNC = "Netui_OnPopupDone_"; + + private String _name = ""; + private HashMap _features; + private boolean _replace = false; + private String _onPopupDone; + + public void setName( String name ) + { + _name = name; + } + + public void setToolbar(boolean toolbar) + { + putFeature("toolbar", toolbar); + } + + public void setLocation(boolean location) + { + putFeature("location", location); + } + + public void setDirectories(boolean directories) + { + putFeature("directories", directories); + } + + public void setStatus(boolean status) + { + putFeature("status", status); + } + + public void setMenubar(boolean menubar) + { + putFeature("menubar", menubar); + } + + public void setScrollbars(boolean scrollbars) + { + putFeature("scrollbars", scrollbars); + } + + public void setResizable(boolean resizable) + { + putFeature("resizable", resizable); + } + + public void setWidth(int width) + { + putFeature("width", width); + } + + public void setHeight(int height) + { + putFeature("height", height); + } + + public void setLeft(int left) + { + putFeature("left", left); + } + + public void setTop(int top) + { + putFeature("top", top); + } + + public void setReplace( boolean replace ) + { + _replace = replace; + } + + public void setOnPopupDone( String onPopupDone ) + { + _onPopupDone = onPopupDone; + } + + public String getOnClick(String url) + { + StringBuilder features = new StringBuilder(); + + if (_features != null) { + boolean firstOne = true; + for (Object i : _features.entrySet()) { + Map.Entry entry = (Map.Entry) i; + if (! firstOne) { + features.append(','); + } + features.append(entry.getKey()); + features.append('='); + features.append(entry.getValue()); + firstOne = false; + } + } + + Object[] args = new Object[]{url, _name, features.toString(), _replace}; + return JavaScriptUtils.getString("popupHelperOnClick", args); + } + + public void addParams(IUrlParams urlParams, IIdProvider idProvider, ServletRequest request) + throws JspException + { + urlParams.addParameter(InternalConstants.RETURN_ACTION_VIEW_RENDERER_PARAM, VIEW_RENDERER_CLASS_NAME, null); + if (_onPopupDone == null) { + _onPopupDone = ON_POPUP_DONE_FUNC + idProvider.getNextId(request); + } + urlParams.addParameter(ReturnActionViewRenderer.getCallbackParamName(), _onPopupDone, null); + } + + public void writeScript(JavaScriptUtils jsu, IScriptReporter scriptReporter, AbstractRenderAppender results) + { + // Write the generic function for popping a window. + jsu.writePopupFunc(scriptReporter, results); + + // Write the callback that's triggered when the popup window is closing. + assert (_onPopupDone != null); // addParams() should ensure that this isn't null + String func = JavaScriptUtils.getString("popupHelperOnPopupDone", new Object[]{_onPopupDone}); + if (scriptReporter != null) { + scriptReporter.addScriptFunction(func); + } + else { + JavaScriptUtils.writeScriptBlock(results, func); + } + } + + private void putFeature(String featureName, boolean val) + { + putFeature(featureName, val ? 1 : 0); + } + + private void putFeature(String featureName, Object val) + { + if (_features == null) { + _features = new HashMap(); + } + _features.put(featureName, val); + } +} + Added: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RetrievePopupOutput.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RetrievePopupOutput.java?view=auto&rev=125603 ============================================================================== --- (empty file) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RetrievePopupOutput.java Wed Jan 19 02:05:34 2005 @@ -0,0 +1,127 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * $Header:$ + */ +package org.apache.beehive.netui.tags.html; + +import org.apache.beehive.netui.util.Bundle; +import org.apache.beehive.netui.tags.AbstractClassicTag; +import org.apache.beehive.netui.tags.internal.ReturnActionViewRenderer; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.JspTag; +import javax.servlet.jsp.tagext.SimpleTagSupport; + + +/** + * Causes a value to be retrieved when a popup window closes. + * @jsptagref.tagdescription Causes a value to be retrieved when a popup window closes. + * @example + * + * <pre> + * <netui:anchor action="getZip"> + * Look up a zip code + * <netui:configurePopup resizable="false" width="400" height="200"> + * Search Google with the query "Socrates" + * <netui:retrievePopupOutput fieldId="zipCodeField" expressionToRetrieve="outputFormBean.zipCode" /> + * </netui:configurePopup> + * </netui:anchor></pre> + * @netui:tag name="retrievePopupOutput" description="Causes a value to be retrieved when a popup window closes." + * @netui.tldx:tag requiredparent="configurePopup" + * requiredchild="#nothing" + * renderer="TODO" + * bodycontentpref="empty" + * whitespace="indent" + */ +public class RetrievePopupOutput + extends AbstractClassicTag +{ + private String _fieldId = null; + private String _expressionToRetrieve = null; + + /** + * Return the name of the Tag. + */ + public String getTagName() + { + return "RetrievePopupOutput"; + } + + /** + * Sets the ID of the form field to populate with a popup output. + * @param fieldId - the ID of the form field to populate with a popup output. + * @jsptagref.attributedescription The ID of the form field to populate with a popup output. + * @jsptagref.databindable false + * @jsptagref.attributesyntaxvalue <i>string_fieldId</i> + * @netui:attribute required="true" rtexprvalue="true" + * description="The ID of the form field to populate with a popup output." + */ + public void setFieldId(String fieldId) + { + _fieldId = fieldId; + } + + /** + * Sets an expression to be evaluated and retrieved from the popup window. + * @param expressionToRetrieve - an expression to be evaluated and retrieved from the popup window. + * @jsptagref.attributedescription An expression to be evaluated and retrieved from the popup window. + * @jsptagref.databindable false + * @jsptagref.attributesyntaxvalue <i>string_expressionToRetrieve</i> + * @netui:attribute required="true" rtexprvalue="true" + * description="An expression to be evaluated and retrieved from the popup window." + * @netui.tldx:attribute + */ + public void setExpressionToRetrieve(String expressionToRetrieve) + { + _expressionToRetrieve = expressionToRetrieve; + } + + /** + * @throws JspException if a JSP exception has occurred + */ + public int doStartTag() throws JspException + { + JspTag parentTag = SimpleTagSupport.findAncestorWithClass(this, ConfigurePopup.class); + if (parentTag == null) { + String msg = Bundle.getString("Tags_InvalidRetrievePopupOutputParent"); + registerTagError(msg, null); + reportErrors(); + } + else { + JspTag parentParent = SimpleTagSupport.findAncestorWithClass(this, IUrlParams.class); + if (parentTag != null) // there will already be an error on ConfigurePopup if there is no URLParams parent. + { + IUrlParams urlParams = (IUrlParams) parentParent; + urlParams.addParameter(ReturnActionViewRenderer.getMapItemParamName(), + _expressionToRetrieve + ReturnActionViewRenderer.getDelim() + _fieldId, + null); + } + } + localRelease(); + return SKIP_BODY; + } + + /** + * Release any acquired resources. + */ + protected void localRelease() + { + super.localRelease(); + + _expressionToRetrieve = null; + _fieldId = null; + } +} Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ScriptHeader.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ScriptHeader.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ScriptHeader.java&r1=125602&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ScriptHeader.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ScriptHeader.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ScriptHeader.java Wed Jan 19 02:05:34 2005 @@ -68,7 +68,7 @@ /** * @param treeSupport - the features * @netui:attribute required="false" rtexprvalue="true" type="boolean" - * description="Generate support the the Tree tag." + * description="Generate support for the Tree tag." * @netui.tldx:attribute category="general" */ public void setTreeSupport(boolean treeSupport) Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/javaScript.properties Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/javaScript.properties?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/javaScript.properties&r1=125602&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/javaScript.properties&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/javaScript.properties (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/javaScript.properties Wed Jan 19 02:05:34 2005 @@ -36,6 +36,37 @@ # The action event that will call the form submit javascript anchorFormSubmitAction=anchor_submit_form("{0}","{1}");return false; +# generic method to open a popup window +popupFunc=\ +function netui_popup(url, name, features, replace)\n\ +{\n\ +\ wnd=open(url, name, features, replace);\n\ +\ if (wnd.opener == null) wnd.opener=self;\n\ +}\n + +# Open a popup window +popupHelperOnClick=netui_popup("{0}","{1}","{2}",{3});return false; + +popupHelperOnPopupDone=\ +function {0}(map)\n\ +'{'\n\ +\ for (var i in map)\n\ +\ '{'\n\ +\ document.getElementById(i).value=map[i];\n\ +\ '}'\n\ +'}'\n + +popupReturn_begin=\ +var map = new Object();\n + +popupReturn_item=\ +map["{0}"] = "{1}";\n + +popupReturn_end=\ +top.opener.{0}(map);\n\ +window.close();\n + + # This script will run and set the focus onto the named element # It is a page level statement that runs to set the initial focus on # the page. @@ -210,9 +241,6 @@ #This method will invoke the NetUICommand infrastructure netuiAction=\ return netUI.action("{0}"); - - - Added: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/internal/IIdProvider.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/internal/IIdProvider.java?view=auto&rev=125603 ============================================================================== --- (empty file) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/internal/IIdProvider.java Wed Jan 19 02:05:34 2005 @@ -0,0 +1,25 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * $Header:$ + */ +package org.apache.beehive.netui.tags.internal; + +import javax.servlet.ServletRequest; + +public interface IIdProvider +{ + public int getNextId(ServletRequest req); +} Added: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/internal/ReturnActionViewRenderer.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/internal/ReturnActionViewRenderer.java?view=auto&rev=125603 ============================================================================== --- (empty file) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/internal/ReturnActionViewRenderer.java Wed Jan 19 02:05:34 2005 @@ -0,0 +1,125 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * $Header:$ + */ +package org.apache.beehive.netui.tags.internal; + +import org.apache.beehive.netui.pageflow.internal.InternalConstants; +import org.apache.beehive.netui.pageflow.internal.InternalExpressionUtils; +import org.apache.beehive.netui.pageflow.internal.ViewRenderer; +import org.apache.beehive.netui.tags.html.JavaScriptUtils; +import org.apache.beehive.netui.tags.rendering.ResponseRenderAppender; +import org.apache.beehive.netui.util.logging.Logger; + +import javax.servlet.ServletContext; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.jsp.el.ELException; +import java.io.IOException; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +/** + * Renderer for the "automatic" script-only page that is produced to send a map of values from a popup window + * back to the opener, and to close the popup window. + */ +public class ReturnActionViewRenderer + implements ViewRenderer, Serializable +{ + private static final Logger _log = Logger.getInstance(ReturnActionViewRenderer.class); + + private static char DELIM = ':'; + private static String ITEM_PARAM = InternalConstants.ATTR_PREFIX + "retrieveItem"; + private static String CALLBACK_PARAM = InternalConstants.ATTR_PREFIX + "returnActionCallback"; + + private HashMap _retrieveMap; + private String _callbackFunc; + + public static char getDelim() + { + return DELIM; + } + + public static String getMapItemParamName() + { + return ITEM_PARAM; + } + + public static String getCallbackParamName() + { + return CALLBACK_PARAM; + } + + /** + * Initialize, based on request parameters we're looking for. + */ + public void init( ServletRequest request ) + { + String[] vals = request.getParameterValues(ITEM_PARAM); + + if ( vals != null ) { + _retrieveMap = new HashMap(); + + for ( int i = 0; i < vals.length; i++ ) { + String val = vals[i]; + int delimPos = val.indexOf(DELIM); + if (delimPos != -1) { + String expressionToRetrieve = val.substring(0, delimPos); + String fieldID = val.substring(delimPos + 1); + _retrieveMap.put(fieldID, expressionToRetrieve); + } + } + } + + _callbackFunc = request.getParameter(CALLBACK_PARAM); + } + + public void renderView( ServletRequest request, ServletResponse response, ServletContext servletContext ) + throws IOException + { + ResponseRenderAppender appender = new ResponseRenderAppender(response); + JavaScriptUtils.writeScriptStart(appender); + appender.append(JavaScriptUtils.getString("popupReturn_begin", null)); + assert request instanceof HttpServletRequest : request.getClass().getName(); + HttpServletRequest httpRequest = (HttpServletRequest) request; + + if (_retrieveMap != null) { + for ( Iterator<Map.Entry> i = _retrieveMap.entrySet().iterator(); i.hasNext(); ) { + Map.Entry entry = i.next(); + String fieldID = (String) entry.getKey(); + String expressionToRetrieve = "${" + (String) entry.getValue() + '}'; + try + { + String value = + InternalExpressionUtils.evaluateMessage(expressionToRetrieve, null, httpRequest, servletContext); + String item = + JavaScriptUtils.getString("popupReturn_item", new Object[]{fieldID, value}); + appender.append(item); + } + catch (ELException e) + { + _log.error("Error evaluating expression " + expressionToRetrieve, e); + } + } + } + + appender.append(JavaScriptUtils.getString("popupReturn_end", new Object[]{ _callbackFunc} )); + JavaScriptUtils.writeScriptEnd(appender); + } +} Added: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/rendering/ResponseRenderAppender.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/rendering/ResponseRenderAppender.java?view=auto&rev=125603 ============================================================================== --- (empty file) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/rendering/ResponseRenderAppender.java Wed Jan 19 02:05:34 2005 @@ -0,0 +1,43 @@ +package org.apache.beehive.netui.tags.rendering; + +import org.apache.beehive.netui.util.Bundle; +import org.apache.beehive.netui.util.logging.Logger; + +import javax.servlet.ServletResponse; +import java.io.IOException; +import java.io.PrintWriter; + +public class ResponseRenderAppender extends AbstractRenderAppender +{ + private static final Logger logger = Logger.getInstance(ResponseRenderAppender.class); + + private ServletResponse _response; + + public ResponseRenderAppender(ServletResponse response) + { + _response = response; + } + + public void append(String s) + { + try { + PrintWriter writer = _response.getWriter(); + writer.print(s); + } + catch (IOException e) { + logger.error(Bundle.getString("Tags_WriteException"), e); + } + } + + public void append(char c) + { + try { + PrintWriter writer = _response.getWriter(); + writer.print(c); + } + catch (IOException e) { + logger.error(Bundle.getString("Tags_WriteException"), e); + } + } + +} Modified: incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/DiscoveryUtils.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/DiscoveryUtils.java?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/DiscoveryUtils.java&r1=125602&p2=incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/DiscoveryUtils.java&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/DiscoveryUtils.java (original) +++ incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/DiscoveryUtils.java Wed Jan 19 02:05:34 2005 @@ -25,15 +25,16 @@ import java.io.InputStream; import java.util.Enumeration; import java.util.ArrayList; +import java.util.Map; import java.net.URL; /** - * Utility methods for discovering service classes on the classpath. A service class is declared in the standard way, - * in a file within META-INF/services where the file name is the class name of the service interface, and the file - * contains the class name of the implementation. For example, to declare test.MyServiceImpl as a test.MyService - * implementation, the file META-INF/services/test.MyService is put on classpath (e.g., in a JAR), with contents - * "test.MyServiceImpl". + * Utility methods for discovering implementor classes on the classpath. An implementor class is declared in the + * standard way, in a file within META-INF/services where the file name is the class name of the desired interface, and + * the file contains the class name of the implementation. For example, to declare test.MyServiceImpl as a + * test.MyService implementation, the file META-INF/services/test.MyService is put on classpath (e.g., in a JAR), + * with contents "test.MyServiceImpl". */ public class DiscoveryUtils { @@ -41,7 +42,7 @@ /** - * Get the ClassLoader from which service classes will be discovered and loaded. + * Get the ClassLoader from which implementor classes will be discovered and loaded. */ public static ClassLoader getClassLoader() { @@ -67,12 +68,12 @@ } /** - * Get all service classes (on the context classpath) that implement a given service interface. + * Get all implementor classes (on the context classpath) that implement a given interface. * - * @param interfaceType the Class that represents the service interface. + * @param interfaceType the Class that represents the interface. * @return an array of Classes that are implementations of <code>interfaceType</code>. */ - public static Class[] getServiceClasses( Class interfaceType ) + public static Class[] getImplementorClasses( Class interfaceType ) { String interfaceName = interfaceType.getName(); ArrayList< Class > classes = new ArrayList< Class >(); @@ -88,7 +89,7 @@ if ( _log.isTraceEnabled() ) { - _log.trace( "Found service entry for interface " + interfaceName + " at " + url ); + _log.trace( "Found implementor entry for interface " + interfaceName + " at " + url ); } InputStream is = null; @@ -99,15 +100,12 @@ is = url.openStream(); BufferedReader reader = new BufferedReader( new InputStreamReader( is ) ); className = reader.readLine().trim(); - Class serviceClass = loadServiceClass( className, interfaceType, classLoader ); - if ( serviceClass != null ) classes.add( serviceClass ); + Class implementorClass = loadImplementorClass( className, interfaceType, classLoader ); + if ( implementorClass != null ) classes.add( implementorClass ); } catch ( IOException ioe ) { - if ( _log.isErrorEnabled() ) - { - _log.error( "Could not read service class entry at + " + url ); - } + _log.error( "Could not read implementor class entry at + " + url ); } finally { @@ -117,57 +115,75 @@ } catch ( IOException e ) { - if ( _log.isErrorEnabled() ) + _log.error( "Could not discover implementors for " + interfaceName, e ); + } + + return classes.toArray( new Class[0] ); + } + + public static Object newImplementorInstance( String className, Class interfaceType ) + { + Class implementorClass = loadImplementorClass( className, interfaceType ); + + if ( implementorClass != null ) + { + try + { + return implementorClass.newInstance(); + } + catch ( IllegalAccessException e ) { - _log.error( "Could not discover services for " + interfaceName, e ); + _log.error( "Could not instantiate " + className + " for interface " + interfaceType.getName(), e ); + } + catch ( InstantiationException e ) + { + _log.error( "Could not instantiate " + className + " for interface " + interfaceType.getName(), e ); } } - return classes.toArray( new Class[0] ); + return null; } /** - * Load a service class from the context classloader. + * Load an implementor class from the context classloader. * - * @param className the name of the service class. - * @param interfaceType the service interface that the given class should implement. - * @return the service Class, or <code>null</code> if an error occurred (the error will be logged). + * @param className the name of the implementor class. + * @param interfaceType the interface that the given class should implement. + * @return the implementor Class, or <code>null</code> if an error occurred (the error will be logged). */ - public static Class loadServiceClass( String className, Class interfaceType ) + public static Class loadImplementorClass( String className, Class interfaceType ) { - return loadServiceClass( className, interfaceType, getClassLoader() ); + return loadImplementorClass( className, interfaceType, getClassLoader() ); } /** - * Load a service class from the context classloader. + * Load an implementor class from the context classloader. * - * @param className the name of the service class. - * @param interfaceType the service interface that the given class should implement. - * @param classLoader the ClassLoader from which to load the service class. - * @return the service Class, or <code>null</code> if an error occurred (the error will be logged). + * @param className the name of the implementor class. + * @param interfaceType the interface that the given class should implement. + * @param classLoader the ClassLoader from which to load the implementor class. + * @return the implementor Class, or <code>null</code> if an error occurred (the error will be logged). */ - private static Class loadServiceClass( String className, Class interfaceType, ClassLoader classLoader ) + private static Class loadImplementorClass( String className, Class interfaceType, ClassLoader classLoader ) { try { if ( _log.isDebugEnabled() ) { - _log.debug( "Trying to load service class for interface " + interfaceType.getName() + ": " + className ); + _log.debug( "Trying to load implementor class for interface " + interfaceType.getName() + + ": " + className ); } - Class serviceClass = classLoader.loadClass( className ); + Class implementorClass = classLoader.loadClass( className ); - if ( interfaceType.isAssignableFrom( serviceClass ) ) + if ( interfaceType.isAssignableFrom( implementorClass ) ) { - return serviceClass; + return implementorClass; } else { - if ( _log.isErrorEnabled() ) - { - _log.error( "Service class " + className + " does not implement interface " - + interfaceType.getName() ); - } + _log.error( "Implementor class " + className + " does not implement interface " + + interfaceType.getName() ); } } catch ( ClassNotFoundException cnfe ) @@ -175,19 +191,13 @@ // // This will happen when the user class was built against an out-of-date interface. // - if ( _log.isErrorEnabled() ) - { - _log.error( "Could not find service class " + className + " for interface " + interfaceType.getName(), - cnfe ); - } + _log.error( "Could not find implementor class " + className + " for interface " + interfaceType.getName(), + cnfe ); } catch ( LinkageError le ) { - if ( _log.isErrorEnabled() ) - { - _log.error( "Linkage error when loading service class " + className + " for interface " - + interfaceType.getName(), le ); - } + _log.error( "Linkage error when loading implementor class " + className + " for interface " + + interfaceType.getName(), le ); } return null; Modified: incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties?view=diff&rev=125603&p1=incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties&r1=125602&p2=incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties&r2=125603 ============================================================================== --- incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties (original) +++ incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties Wed Jan 19 02:05:34 2005 @@ -30,6 +30,8 @@ Tags_TreeDataNodeNotUnique=Tree node named ''{0}'' already belongs to this tree. Tags_InvalidParameterParent=Parameter tag's parent must implement URLParams. Tags_InvalidParameterMapParent=ParameterMap tag's parent must implement URLParams. +Tags_InvalidConfigurePopupParent=ConfigurePopup tag's parent must implement IHasPopupSupport. +Tags_InvalidRetrievePopupOutputParent=RetrievePopupOutput tag's parent must be ConfigurePopup. Tags_ParameterMapNotAMap=Map expression for ParameterMap does not resolve to a java.util.Map. Tags_ParameterMapNotAnException=Map attribute of ParameterMap must be an expression. Tags_InvalidNodeParent=Node's parent must be a Tree or another TreeItem.
