You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ek...@apache.org on 2004/09/10 19:24:09 UTC

svn commit: rev 43679 - in incubator/beehive/trunk/netui: src/pageflow/org/apache/beehive/netui/pageflow src/pageflow/org/apache/beehive/netui/pageflow/internal src/pageflow/org/apache/beehive/netui/script/common src/tags-databinding/org/apache/beehive/netui/tags/databinding/pageinput src/tags-html/org/apache/beehive/netui/tags/html test/webapps/drt/coreWeb/databinding/anybean test/webapps/drt/coreWeb/databinding/repeater/booleanChoice test/webapps/drt/coreWeb/tags/bindingUpdateErrors test/webapps/drt/coreWeb/xhtml

Author: ekoneil
Date: Fri Sep 10 10:24:08 2004
New Revision: 43679

Removed:
   incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/databinding/repeater/booleanChoice/
Modified:
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBean.java
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/GlobalApp.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/PageFlowJspFilter.java
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowManagedObject.java
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/SharedFlowController.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/script/common/ImplicitObjectUtil.java
   incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/pageinput/DeclarePageInput.java
   incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java
   incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/databinding/anybean/updateAnyBean.jsp
   incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/bindingUpdateErrors/index.jsp
   incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/xhtml/imageResults.jsp
Log:
Various fixes:

- centralize the handling of dropping JSP 2.0 EL bindable objects into the ImplicitObjectUtil class.  This isn't right yet, but at least it's all in one place now.  Need a better infrastructure for how to expose objects as JSP 2.0 EL bindable.

- add the "required" flag on the declarePageInput tag.  Page inputs are now required by default -- ie present in the page input map and non-null.  To make a page input optional for a given page, this flag needs to be set to "false".  There are a couple of associated test updates here to reflect this change.

- remove the "booleanChoice" directory, which didn't have anything in it.

BB: self
CR: Rich
DRT: NetUI pass
BVt: NetUI pass



Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBean.java
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBean.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBean.java	Fri Sep 10 10:24:08 2004
@@ -42,11 +42,6 @@
         InternalUtils.getServerAdapter().ensureFailover( attr, this, unwrappedRequest );
     }
 
-    void setImplicitObject( HttpServletRequest request )
-    {
-        request.setAttribute( InternalConstants.BACKING_CLASS_IMPLICIT_OBJECT, this );
-    }
-
     public String getDisplayName()
     {
         return getClass().getName();

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/GlobalApp.java
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/GlobalApp.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/GlobalApp.java	Fri Sep 10 10:24:08 2004
@@ -57,9 +57,4 @@
     {
         return GLOBALAPP_SOURCEFILE_NAME;
     }
-    
-    void setImplicitObject( HttpServletRequest request )
-    {
-        request.setAttribute( InternalConstants.GLOBAL_APP_IMPLICIT_OBJECT_NAME, this );
-    }
 }

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowController.java
==============================================================================
--- 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	Fri Sep 10 10:24:08 2004
@@ -770,11 +770,6 @@
         return info;
     }
 
-    void setImplicitObject( HttpServletRequest request )
-    {
-        request.setAttribute( InternalConstants.PAGE_FLOW_IMPLICIT_OBJECT_NAME, this );
-    }
-
     final void beforePage()
     {
         HttpServletRequest request = getRequest();

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowJspFilter.java
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowJspFilter.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowJspFilter.java	Fri Sep 10 10:24:08 2004
@@ -33,6 +33,7 @@
 import org.apache.struts.config.ModuleConfig;
 
 import org.apache.beehive.netui.script.common.BundleMap;
+import org.apache.beehive.netui.script.common.ImplicitObjectUtil;
 import org.apache.beehive.netui.util.logging.Logger;
 import org.apache.beehive.netui.util.FileUtils;
 import org.apache.beehive.netui.util.ServletUtils;
@@ -250,26 +251,25 @@
         }
     }
     
-    private void setImplicitObjects( HttpServletRequest request, HttpServletResponse response,
-                                     PageFlowController curJpf )
+    private void setImplicitObjects( HttpServletRequest request, HttpServletResponse response, PageFlowController curJpf )
     {
         // @todo: need to wrap this in checks for JSP 1.2
-        // @todo: feature: need to add support for chaining in user-code to
-        //        run when setting implicit objects on the request
+        // @todo: feature: need to add support for chaining in user-code to run when setting implicit objects on the request
         if ( curJpf != null )
         {
-            curJpf.setImplicitObject( request );
             FacesBackingBean fbb =
                     FacesBackingBeanFactory.getFacesBackingBeanForRequest( request, response, _servletContext );
-            if ( fbb != null ) fbb.setImplicitObject( request );
-            request.setAttribute( "pageInput", InternalUtils.getActionOutputMap( request, false ) );
+            ImplicitObjectUtil.loadPageFlow(request, curJpf, fbb);
         }
         
         SharedFlowController sf = FlowControllerFactory.getSharedFlowForRequest( request, response, _servletContext );
-        if ( sf != null ) sf.setImplicitObject( request );
+        ImplicitObjectUtil.loadSharedFlow(request, sf);
+
+        // @todo: need to move bundleMap creation to a BundleMapFactory
         BundleMap bundleMap = new BundleMap( request, _servletContext, null );
-        request.setAttribute( "bundle", bundleMap );
+        ImplicitObjectUtil.loadBundleMap(request, bundleMap);
     }
+
     /**
      * Make sure that when this JSP is rendered, it will set headers in the response to prevent caching.
      * Because these headers are lost on server forwards, we set a request attribute to cause the headers

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowManagedObject.java
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowManagedObject.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowManagedObject.java	Fri Sep 10 10:24:08 2004
@@ -224,8 +224,6 @@
     {
         return _servletContext;
     }
-
-    abstract void setImplicitObject( HttpServletRequest request );
     
     public abstract String getDisplayName();
 }

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/SharedFlowController.java
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/SharedFlowController.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/SharedFlowController.java	Fri Sep 10 10:24:08 2004
@@ -127,9 +127,4 @@
     {
         PageFlowUtils.deleteSharedFlow( getClass().getName(), getRequest() );
     }
-    
-    void setImplicitObject( HttpServletRequest request )
-    {
-        request.setAttribute( InternalConstants.SHARED_FLOW_IMPLICIT_OBJECT_NAME, this );
-    }
 }

Modified: 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/InternalConstants.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalConstants.java	Fri Sep 10 10:24:08 2004
@@ -28,10 +28,6 @@
     
     public static final String FACES_BACKING_ATTR = InternalUtils.class.getName() + "_facesBacking";
     public static final String BACKING_CLASS_IMPLICIT_OBJECT = "backing";
-
-    public static final String GLOBAL_APP_IMPLICIT_OBJECT_NAME = "globalApp";
-    public static final String PAGE_FLOW_IMPLICIT_OBJECT_NAME = "pageFlow";
-    public static final String SHARED_FLOW_IMPLICIT_OBJECT_NAME = "sharedFlow";
     
     public static final String SHARED_FLOW_MODULE_PREFIX = "/-";
     public static final String SHARED_FLOW_ROOT_MODULE = "/-webappRoot";

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/script/common/ImplicitObjectUtil.java
==============================================================================
--- 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	Fri Sep 10 10:24:08 2004
@@ -24,17 +24,17 @@
 
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
+import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.jsp.PageContext;
+import javax.servlet.jsp.JspContext;
 import javax.servlet.jsp.el.VariableResolver;
 import javax.servlet.jsp.tagext.Tag;
 import javax.servlet.jsp.tagext.JspTag;
 
 // internal imports
-import org.apache.beehive.netui.pageflow.GlobalApp;
-import org.apache.beehive.netui.pageflow.PageFlowController;
-import org.apache.beehive.netui.pageflow.PageFlowUtils;
+import org.apache.beehive.netui.pageflow.*;
 import org.apache.beehive.netui.pageflow.internal.AnyBeanActionForm;
 import org.apache.beehive.netui.pageflow.internal.InternalUtils;
 
@@ -55,9 +55,47 @@
 {
     private static final Logger _logger = Logger.getInstance(ImplicitObjectUtil.class);
     private static final String IMPLICIT_OBJECT_BEAN = (ImplicitObjectBean.class).getName() + "_KEY";
-    
+    private static final String PAGE_FLOW_IMPLICIT_OBJECT_KEY = "pageFlow";
+    private static final String SHARED_FLOW_IMPLICIT_OBJECT_KEY = "sharedFlow";
+    private static final String BUNDLE_IMPLICIT_OBJECT_KEY = "bundle";
+    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 ImplicitObjectUtil() {}
 
+    public static final void loadActionForm(JspContext jspContext, Object form)
+    {
+        jspContext.setAttribute(ACTION_FORM_IMPLICIT_OBJECT_KEY, unwrapForm(form));
+    }
+
+    public static final void unloadActionForm(JspContext jspContext)
+    {
+        jspContext.removeAttribute(ACTION_FORM_IMPLICIT_OBJECT_KEY);
+    }
+
+    public static final void loadPageFlow(ServletRequest request, PageFlowController pageFlow, FacesBackingBean fbb)
+    {
+        if(pageFlow == null)
+            return;
+
+        request.setAttribute(PAGE_FLOW_IMPLICIT_OBJECT_KEY, pageFlow);
+        if(fbb != null)
+            request.setAttribute(BACKING_IMPLICIT_OBJECT_KEY, fbb);
+        request.setAttribute(PAGE_INPUT_IMPLICIT_OBJECT_KEY, InternalUtils.getActionOutputMap(request, false));
+    }
+
+    public static final void loadSharedFlow(ServletRequest request, SharedFlowController sharedFlow)
+    {
+        if (sharedFlow != null)
+            request.setAttribute(SHARED_FLOW_IMPLICIT_OBJECT_KEY, sharedFlow);
+    }
+
+    public static final void loadBundleMap(ServletRequest servletRequest, BundleMap bundleMap)
+    {
+        servletRequest.setAttribute(BUNDLE_IMPLICIT_OBJECT_KEY, bundleMap);
+    }
+
     public static final ImplicitObjectBean getImplicitObjects(PageContext pageContext, JspTag currentTag)
     {
         ImplicitObjectBean bean = (ImplicitObjectBean)pageContext.getRequest().getAttribute(IMPLICIT_OBJECT_BEAN);
@@ -237,15 +275,13 @@
         return map;
     }
 
-    private static final Object unwrapForm(ActionForm form)
+    private static final Object unwrapForm(Object form)
     {
-        Object realForm = form;
-        if(form instanceof AnyBeanActionForm)
-            realForm = ((AnyBeanActionForm)form).getBean();
-        
-        if(_logger.isDebugEnabled()) 
-            _logger.debug("using form of type: " + (realForm != null ? realForm.getClass().getName() : "null"));
+        if(_logger.isDebugEnabled() && form instanceof AnyBeanActionForm)
+            _logger.debug("using form of type: " + ((AnyBeanActionForm)form != null ? ((AnyBeanActionForm)form).getClass().getName() : "null"));
 
-        return realForm;
+        if(form instanceof AnyBeanActionForm)
+            return ((AnyBeanActionForm)form).getBean();
+        else return form;
     }
 }

Modified: incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/pageinput/DeclarePageInput.java
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/pageinput/DeclarePageInput.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/pageinput/DeclarePageInput.java	Fri Sep 10 10:24:08 2004
@@ -152,7 +152,7 @@
 
     private String _type = null;
     private String _name = null;
-    private boolean _required = false;
+    private boolean _required = true;
 
     /**
      * Set the name of a variable that can be referecned using the page 
@@ -276,8 +276,7 @@
         }
 
         Map actionOutputMap = InternalUtils.getActionOutputMap(pageContext.getRequest(), false);
-        if(_required && 
-           (actionOutputMap == null || !actionOutputMap.containsKey(_name)))
+        if(_required && (actionOutputMap == null || !actionOutputMap.containsKey(_name)))
         {
             String msg = Bundle.getErrorString("Tags_DeclarePageInput_Required", new Object[] {_name});
             registerTagError(msg, null);

Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java	Fri Sep 10 10:24:08 2004
@@ -32,6 +32,7 @@
 import org.apache.beehive.netui.tags.rendering.TagRenderingBase;
 import org.apache.beehive.netui.util.Bundle;
 import org.apache.beehive.netui.util.ParamHelper;
+import org.apache.beehive.netui.script.common.ImplicitObjectUtil;
 import org.apache.struts.Globals;
 import org.apache.struts.action.ActionForm;
 import org.apache.struts.action.ActionMapping;
@@ -681,7 +682,8 @@
         }
         if (bean != null) {
             pageContext.setAttribute(Constants.BEAN_KEY, bean,PageContext.REQUEST_SCOPE);
-            pageContext.setAttribute("actionForm", bean);
+
+            ImplicitObjectUtil.loadActionForm(pageContext, bean);
         }
 
         // Continue processing this page
@@ -825,7 +827,7 @@
         // Remove the page scope attributes we created
         pageContext.removeAttribute(Constants.BEAN_KEY, PageContext.REQUEST_SCOPE);
         pageContext.removeAttribute(Constants.FORM_KEY, PageContext.REQUEST_SCOPE);
-        pageContext.removeAttribute("actionForm"); 
+        ImplicitObjectUtil.unloadActionForm(pageContext);
 
         // output the hidden fields for id transparency if this is turned on
         if (HtmlBaseTag.isIdTransparency(servletContext)) {

Modified: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/databinding/anybean/updateAnyBean.jsp
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/databinding/anybean/updateAnyBean.jsp	(original)
+++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/databinding/anybean/updateAnyBean.jsp	Fri Sep 10 10:24:08 2004
@@ -2,7 +2,6 @@
 <%@ taglib uri="beehive-netui-tags-databinding.tld" prefix="netui-data"%>
 <%@ taglib uri="beehive-netui-tags-html.tld" prefix="netui"%>
 <%@ taglib uri="beehive-netui-tags-template.tld" prefix="netui-template"%>
-<netui-data:declarePageInput name="postedForm" type="databinding.anybean.Controller.Customer"/>
 <netui:html>
     <head>
         <netui:base/>

Modified: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/bindingUpdateErrors/index.jsp
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/bindingUpdateErrors/index.jsp	(original)
+++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/bindingUpdateErrors/index.jsp	Fri Sep 10 10:24:08 2004
@@ -35,7 +35,7 @@
             <br/>&nbsp;
             <netui:button value="postName" type="submit"/>&nbsp;
         <hr>
-        <netui:bindingUpdateErrors/><br>
+        <netui:bindingUpdateErrors alwaysReport="true"/><br>
         Errors for actionForm.firstName: <netui:bindingUpdateErrors alwaysReport="true"  expression="actionForm.firstName"/><br>
         Errors for actionForm.lastame: <netui:bindingUpdateErrors alwaysReport="true" expression="actionForm.lastName"/><br>
          </netui:form>

Modified: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/xhtml/imageResults.jsp
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/xhtml/imageResults.jsp	(original)
+++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/xhtml/imageResults.jsp	Fri Sep 10 10:24:08 2004
@@ -2,8 +2,8 @@
 <%@ taglib uri="beehive-netui-tags-databinding.tld" prefix="netui-data"%>
 <%@ taglib uri="beehive-netui-tags-html.tld" prefix="netui"%>
 <%@ taglib uri="beehive-netui-tags-template.tld" prefix="netui-template"%>
-<netui-data:declarePageInput name="formData" type="xhtml.Controller.SelectTests"/>
-<netui-data:declarePageInput name="action" type="java.lang.String"/>
+<netui-data:declarePageInput name="formData" type="xhtml.Controller.SelectTests" required="false"/>
+<netui-data:declarePageInput name="action" type="java.lang.String" required="false"/>
 <netui:html documentType="xhtml1-transitional">
     <head>
         <title>Image Post Results</title>