beehive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: rev 46002 - in incubator/beehive/trunk/netui: src/pageflow/org/apache/beehive/netui/pageflow src/pageflow/org/apache/beehive/netui/pageflow/annotations src/pageflow/org/apache/beehive/netui/pageflow/internal src/util/org/apache/beehive/netui/util src/webapp-template/dd/generic test/webapps/drt/coreWeb/WEB-INF test/webapps/jsf/jsfWeb/WEB-INF test/webapps/jsf/jsfWeb/initMemberFields test/webapps/jsf/testRecorder/config test/webapps/jsf/testRecorder/tests test/webapps/testRecorder-test/testRecorder-test/WEB-INF test/webapps/urlTemplates/urlTemplates/WEB-INF test/webapps/webappBuild-test/webappBuild-test/WEB-INF
Date Mon, 13 Sep 2004 23:26:08 GMT
Author: rich
Date: Mon Sep 13 16:26:08 2004
New Revision: 46002

Added:
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowFacesFilter.java   (contents, props changed)
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowPageFilter.java   (contents, props changed)
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/CachedFacesBackingInfo.java   (contents, props changed)
   incubator/beehive/trunk/netui/test/webapps/jsf/jsfWeb/initMemberFields/
   incubator/beehive/trunk/netui/test/webapps/jsf/jsfWeb/initMemberFields/InitMemberFieldsController.jpf   (contents, props changed)
   incubator/beehive/trunk/netui/test/webapps/jsf/jsfWeb/initMemberFields/InitMemberFieldsSharedFlow.jpfs   (contents, props changed)
   incubator/beehive/trunk/netui/test/webapps/jsf/jsfWeb/initMemberFields/page1.jsfb   (contents, props changed)
   incubator/beehive/trunk/netui/test/webapps/jsf/jsfWeb/initMemberFields/page1.jsp   (contents, props changed)
   incubator/beehive/trunk/netui/test/webapps/jsf/testRecorder/tests/InitMemberFields.xml   (contents, props changed)
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/PageFlowController.java
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowFileFilter.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/annotations/Jpf.java
   incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/ServletUtils.java
   incubator/beehive/trunk/netui/src/webapp-template/dd/generic/web.xml
   incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/web.xml
   incubator/beehive/trunk/netui/test/webapps/jsf/jsfWeb/WEB-INF/web.xml
   incubator/beehive/trunk/netui/test/webapps/jsf/testRecorder/config/testRecorder-tests.xml
   incubator/beehive/trunk/netui/test/webapps/testRecorder-test/testRecorder-test/WEB-INF/web.xml
   incubator/beehive/trunk/netui/test/webapps/urlTemplates/urlTemplates/WEB-INF/web.xml
   incubator/beehive/trunk/netui/test/webapps/webappBuild-test/webappBuild-test/WEB-INF/web.xml
Log:
- Added auto-initialization of annotated shared flow and page flow member fields in JSF backing files.  This works like the @Jpf.SharedFlow field initialization in PageFlowController:
        @Jpf.SharedFlowField
        MySharedFlow _sharedFlow;   // initialized with the current shared flow

        @Jpf.PageFlowField
        MyPageFlow _pageFlow;       // initialized with the current page flow

- Split out a separate PageFlowFacesFilter, to be run before *.faces.  Currently, it's almost identical to PageFlowJspFilter, but this gives us room to do JSF-specific things in the future without requiring updates to all web.xml files.

DRT: netui (WinXP)
BB: self (linux)



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	Mon Sep 13 16:26:08 2004
@@ -19,20 +19,25 @@
 
 import org.apache.beehive.netui.pageflow.internal.InternalConstants;
 import org.apache.beehive.netui.pageflow.internal.InternalUtils;
+import org.apache.beehive.netui.pageflow.internal.CachedFacesBackingInfo;
 import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
+import org.apache.beehive.netui.util.cache.ClassLevelCache;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.ServletContext;
-import javax.faces.context.FacesContext;
 import java.util.Map;
 import java.util.Collections;
+import java.lang.reflect.Field;
 
 public abstract class FacesBackingBean
         extends PageFlowManagedObject
 {
+    private static final String CACHED_INFO_KEY = "cachedInfo";
+    
     private Map _pageInputs;
     
+    
     void persistInSession( HttpServletRequest request, HttpServletResponse response, ServletContext servletContext )
     {
         HttpServletRequest unwrappedRequest = PageFlowUtils.unwrapMultipart( request );
@@ -60,6 +65,30 @@
             if ( map != null ) _pageInputs = Collections.unmodifiableMap( map );
         }
         
+        //
+        // Initialize the page flow field.
+        //
+        Field pageFlowMemberField = getCachedInfo().getPageFlowMemberField();
+        
+        // TODO: should we add a compiler warning if this field isn't transient?  All this reinitialization logic is
+        // for the transient case.
+        if ( fieldIsUninitialized( pageFlowMemberField ) )
+        {
+            PageFlowController pfc = PageFlowUtils.getCurrentPageFlow( request );
+            initializeField( pageFlowMemberField, pfc );
+        }
+        
+        //
+        // Initialize the shared flow field.
+        //
+        Field sharedFlowMemberField = getCachedInfo().getSharedFlowMemberField();
+        
+        if ( fieldIsUninitialized( sharedFlowMemberField ) )
+        {
+            SharedFlowController sf = PageFlowUtils.getSharedFlow( request, servletContext );
+            initializeField( sharedFlowMemberField, sf );
+        }
+        
         super.reinitialize( request, response, servletContext );
     }
 
@@ -68,16 +97,22 @@
         return _pageInputs != null ? _pageInputs.get( pageInputName ) : null;
     }
     
-    private static HttpServletRequest getRequest( FacesContext context )
+    public Map getPageInputMap()
     {
-        Object request = context.getExternalContext().getRequest();
-        assert request != null;
-        assert request instanceof HttpServletRequest : request.getClass().getName();
-        return ( HttpServletRequest ) request;
+        return _pageInputs;
     }
     
-    public Map getPageInputMap()
+    private CachedFacesBackingInfo getCachedInfo()
     {
-        return _pageInputs;
+        ClassLevelCache cache = ClassLevelCache.getCache( getClass() );
+        CachedFacesBackingInfo info = ( CachedFacesBackingInfo ) cache.getCacheObject( CACHED_INFO_KEY );
+        
+        if ( info == null )
+        {
+            info = new CachedFacesBackingInfo( getClass() );
+            cache.setCacheObject( CACHED_INFO_KEY, info );
+        }
+        
+        return info;
     }
 }

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	Mon Sep 13 16:26:08 2004
@@ -34,7 +34,6 @@
 import org.apache.beehive.netui.pageflow.config.PageFlowControllerConfig;
 import org.apache.beehive.netui.pageflow.internal.CachedPageFlowInfo;
 import org.apache.beehive.netui.pageflow.internal.InternalUtils;
-import org.apache.beehive.netui.pageflow.internal.InternalConstants;
 import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
 
 
@@ -85,7 +84,7 @@
     /**
      * Default constructor.
      */ 
-    public PageFlowController()
+    protected PageFlowController()
     {
     }
     
@@ -243,44 +242,14 @@
     }
     
     private void initializeSharedFlowField( HttpServletRequest request, HttpServletResponse response, 
-                                           ServletContext servletContext )
+                                            ServletContext servletContext )
     {
-        //
-        // Initialize the SharedFlowController field.
-        //
         Field sharedFlowMemberField = getCachedInfo().getSharedFlowMemberField();
         
-        try
-        {
-            if ( sharedFlowMemberField != null && sharedFlowMemberField.get( this ) == null )
-            {
-                SharedFlowController sf = InternalUtils.getSharedFlow( this, request, response, servletContext );
-                
-                if ( sf != null )
-                {
-                    if ( _log.isTraceEnabled() )
-                    {
-                        _log.trace( "Initializing field " + sharedFlowMemberField.getName() + " in " + this
-                                    + " with SharedFlowController " + sf );
-                    }
-                    
-                    try
-                    {
-                        sharedFlowMemberField.set( this, sf );
-                    }
-                    catch ( IllegalArgumentException e )
-                    {
-                        _log.error( "Could not set field " + sharedFlowMemberField.getName() + " on "
-                                    + getDisplayName() + "; SharedFlowController is of type "
-                                    + sf.getClass().getName() + ", field type is "
-                                    + sharedFlowMemberField.getType().getName() );
-                    }
-                }
-            }
-        }
-        catch ( IllegalAccessException e )
+        if ( fieldIsUninitialized( sharedFlowMemberField ) )
         {
-            _log.error( "Error initializing SharedFlowController field " + sharedFlowMemberField.getName(), e );
+            SharedFlowController sf = InternalUtils.getSharedFlow( this, request, response, servletContext );
+            initializeField( sharedFlowMemberField, sf );
         }
     }
     
@@ -781,7 +750,7 @@
         // path.
         //
         String path = getCurrentForwardPath();
-        if ( ( path == null ) || ! path.equals( relativeUri ) )
+        if ( path == null || ! path.equals( relativeUri ) )
         {
             ActionForward actionForward = new ActionForward( relativeUri );
             actionForward.setContextRelative( true );

Added: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowFacesFilter.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowFacesFilter.java	Mon Sep 13 16:26:08 2004
@@ -0,0 +1,44 @@
+/*
+ * 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;
+
+import org.apache.beehive.netui.pageflow.internal.InternalConstants;
+
+import java.util.HashSet;
+import java.util.Set;
+
+
+/**
+ * Servlet Filter for JavaServerFaces requests.
+ */ 
+public class PageFlowFacesFilter
+        extends PageFlowPageFilter
+{
+    private static Set< String > VALID_FILE_EXTENSIONS = new HashSet< String >();
+    
+    static
+    {
+        VALID_FILE_EXTENSIONS.add( InternalConstants.FACES_EXTENSION );
+        VALID_FILE_EXTENSIONS.add( InternalConstants.JSF_EXTENSION );
+    }
+    
+    protected Set getValidFileExtensions()
+    {
+        return VALID_FILE_EXTENSIONS;
+    }
+}

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowFileFilter.java
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowFileFilter.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowFileFilter.java	Mon Sep 13 16:26:08 2004
@@ -25,6 +25,7 @@
 
 /**
  * File filter that accepts any {@link PageFlowController} source file (*.jpf).
+ * @deprecated
  */ 
 public class PageFlowFileFilter implements FilenameFilter
 {

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	Mon Sep 13 16:26:08 2004
@@ -17,283 +17,26 @@
  */
 package org.apache.beehive.netui.pageflow;
 
-import javax.servlet.Filter;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.FilterChain;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.Set;
 import java.util.HashSet;
+import java.util.Set;
 
-import org.apache.struts.util.RequestUtils;
-import org.apache.struts.action.ActionServlet;
-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;
-import org.apache.beehive.netui.pageflow.internal.JavaControlUtils;
-import org.apache.beehive.netui.pageflow.internal.InternalUtils;
-import org.apache.beehive.netui.pageflow.internal.InternalConstants;
 
 /**
- * Servlet filter to ensure that KNEX gets a chance to compile/redeploy if necessary, and
- * to ensure that the current pageflow is instantiated and initialized.
- * 
- * @exclude
+ * Servlet Filter for JSP requests.
  */ 
-public class PageFlowJspFilter implements Filter
+public class PageFlowJspFilter
+        extends PageFlowPageFilter
 {
-    private ServletContext _servletContext;
-    
-    private static final Logger _log = Logger.getInstance( PageFlowJspFilter.class );
-    
     private static Set< String > VALID_FILE_EXTENSIONS = new HashSet< String >();
-    private static final String PREVENT_CACHE_ATTR = PageFlowJspFilter.class.getName() + "_preventCache";
     
     static
     {
         VALID_FILE_EXTENSIONS.add( "jsp" );
         VALID_FILE_EXTENSIONS.add( "jspx" );
-        VALID_FILE_EXTENSIONS.add( InternalConstants.FACES_EXTENSION );
-        VALID_FILE_EXTENSIONS.add( InternalConstants.JSF_EXTENSION );
     }
     
-    
-    public void init( FilterConfig filterConfig ) throws ServletException
-    {
-        _servletContext = filterConfig.getServletContext();
-    }
-
-    public void doFilter( ServletRequest request, ServletResponse response, FilterChain chain )
-        throws IOException, ServletException
-    {
-        if ( request instanceof HttpServletRequest && response instanceof HttpServletResponse )
-        {
-            HttpServletRequest httpRequest = ( HttpServletRequest ) request;
-            HttpServletResponse httpResponse = ( HttpServletResponse ) response;
-            
-            //
-            // Don't do the filter if the request is in error.
-            //
-            Object errStatusCode = request.getAttribute( "javax.servlet.error.status_code" );
-            if ( errStatusCode != null )
-            {
-                if ( _log.isDebugEnabled() )
-                {
-                    _log.debug( "Request has error status code " + errStatusCode + ".  Skipping filter." );
-                }
-
-                chain.doFilter( request, response );        
-
-                return;           
-            }
-            
-            String requestURI = httpRequest.getRequestURI();
-            String extension = FileUtils.getFileExtension( requestURI );
-            
-            if ( ! VALID_FILE_EXTENSIONS.contains( extension ) )
-            {
-                if ( _log.isDebugEnabled() )
-                {
-                    _log.debug( "Request " + requestURI + " is not an appropriate URI.  Skipping filter." );
-                }
-
-                chain.doFilter( request, response );        
-                return;
-            }
-        
-            if ( _log.isDebugEnabled() )
-            {
-                _log.debug( "Filtering request " + requestURI );
-            }
-            
-            //
-            // If at an earlier stage in the request we determined that we should prevent caching,
-            // actually write the appropriate headers to the response now.
-            //
-            if ( request.getAttribute( PREVENT_CACHE_ATTR ) != null )
-            {
-                ServletUtils.preventCache( httpResponse );
-            }
-            
-            //
-            // Callback to the server adapter.
-            //
-            InternalUtils.getServerAdapter().beginRequest( httpRequest, httpResponse, _servletContext );
-            
-            //
-            // Initialize the ControlBeanContext in the session.
-            //
-            JavaControlUtils.initializeControlContext( httpRequest, httpResponse, _servletContext );
-            
-            try
-            {
-                //
-                // Ensure that the right Struts module is selected, for use by the tags.
-                //
-                ModuleConfig prevModuleConfig = RequestUtils.getRequestModuleConfig( httpRequest );
-                String curModulePath = PageFlowUtils.getModulePath( httpRequest );
-                ActionServlet as = InternalUtils.getActionServlet( _servletContext );
-                
-                if ( as instanceof AutoRegisterActionServlet )
-                {
-                    AutoRegisterActionServlet das = ( AutoRegisterActionServlet ) as;
-                    das.ensureModuleRegistered( curModulePath, httpRequest );
-                }
-                
-                RequestUtils.selectModule( curModulePath, httpRequest, _servletContext );
-                
-                if ( RequestUtils.getRequestModuleConfig( httpRequest ) == null )
-                {
-                    //
-                    // If we still haven't had success in selecting the module, see if we can
-                    // dynamically register one.
-                    //
-                    if ( as instanceof AutoRegisterActionServlet )
-                    {
-                        AutoRegisterActionServlet das = ( AutoRegisterActionServlet ) as;
-                        das.ensureModuleSelected( curModulePath, httpRequest, httpResponse );
-                    }
-                }
-                
-                //
-                // Make sure that the current PageFlowController is set up for this request.
-                //
-                PageFlowController curJpf = 
-                        FlowControllerFactory.getPageFlowForRequest( httpRequest, httpResponse, _servletContext );
-                
-                //
-                // If there is no pageflow for the current Struts module, than fall back to default
-                // Struts behavior, which is *not* to allow a .jsp request to set the current module.
-                //
-                if ( curJpf == null )
-                {
-                    InternalUtils.setCurrentModule( prevModuleConfig, request );
-                //InternalUtils.setCurrentPageFlow( null, httpRequest );
-                }
-                
-                
-                if ( _log.isDebugEnabled() )
-                {
-                    _log.debug( "Current PageFlowController is: " + curJpf );
-                    _log.debug( "Continuing with filter chain..." );
-                }
-                
-                //
-                // Make sure that the pageflow's getRequest() and getResponse() will work while the JSP
-                // is being rendered, since methods on the pageflow may be called (through databinding
-                // or tags, or through direct reference).
-                //
-                if ( curJpf != null )
-                {
-                    //
-                    // We're going to bail out if there are too many concurrent requests for the same JPF.
-                    // This prevents an attack that takes advantage of the fact that we synchronize requests
-                    // to the same pageflow.
-                    //
-                    if ( curJpf.incrementRequestCount( httpRequest, httpResponse, _servletContext ) )
-                    {
-                        try
-                        {
-                            //
-                            // Any databinding calls, indirect calls to getRequest(), etc. must be protected
-                            // against conflicts from running action methods at the same time as rendering 
-                            // the JSP here.  Synchronize on the JPF.
-                            //
-                            synchronized ( curJpf )
-                            {
-                                FlowController.PerRequestState newState =
-                                        new FlowController.PerRequestState( httpRequest, httpResponse, null );
-                                FlowController.PerRequestState prevState = curJpf.setPerRequestState( newState );
-                                setImplicitObjects( httpRequest, httpResponse, curJpf );
-
-                                //
-                                // tell the page flow that we're about to display a JSP so it can
-                                // manage settings, such as previous page information, if needed
-                                // in advance.
-                                //
-                                curJpf.beforePage();
-                                
-                                try
-                                {
-                                    chain.doFilter( request, response );
-                                }
-                                finally
-                                {
-                                    curJpf.setPerRequestState( prevState );
-                                }
-                            }
-                        }
-                        finally
-                        {
-                            curJpf.decrementRequestCount( httpRequest );
-                        }
-                    }
-                }
-                else
-                {
-                    setImplicitObjects( httpRequest, httpResponse, null );
-                    chain.doFilter( request, response );
-                }
-            }
-            finally
-            {
-                //
-                // Clean up the ControlBeanContext in the session.
-                //
-                JavaControlUtils.uninitializeControlContext( httpRequest, httpResponse );
-                
-                //
-                // Callback to the server adapter.
-                //
-                InternalUtils.getServerAdapter().endRequest( httpRequest, httpResponse, _servletContext );
-            }
-        }
-        else
-        {
-            chain.doFilter( request, response );            
-        }
-    }
-    
-    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
-        if ( curJpf != null )
-        {
-            FacesBackingBean fbb =
-                    FacesBackingBeanFactory.getFacesBackingBeanForRequest( request, response, _servletContext );
-            ImplicitObjectUtil.loadPageFlow(request, curJpf, fbb);
-        }
-        
-        SharedFlowController sf = FlowControllerFactory.getSharedFlowForRequest( request, response, _servletContext );
-        ImplicitObjectUtil.loadSharedFlow(request, sf);
-
-        // @todo: need to move bundleMap creation to a BundleMapFactory
-        BundleMap bundleMap = new BundleMap( request, _servletContext, null );
-        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
-     * to be set right before the JSP is rendered.
-     */ 
-    static void preventCache( HttpServletRequest request )
-    {
-        request.setAttribute( PREVENT_CACHE_ATTR, Boolean.TRUE );
-    }
-
-    public void destroy()
+    protected Set getValidFileExtensions()
     {
-        _servletContext = null;
+        return VALID_FILE_EXTENSIONS;
     }
 }

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	Mon Sep 13 16:26:08 2004
@@ -18,6 +18,7 @@
 package org.apache.beehive.netui.pageflow;
 
 import org.apache.beehive.netui.pageflow.internal.JavaControlUtils;
+import org.apache.beehive.netui.pageflow.internal.InternalUtils;
 import org.apache.beehive.netui.pageflow.scoping.ScopedRequest;
 import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
 import org.apache.beehive.netui.util.logging.Logger;
@@ -180,6 +181,9 @@
         }
     }
 
+    /**
+     * Create a unique ID for a given Java Control field.
+     */ 
     private String getControlID( Field controlField, HttpServletRequest request )
     {
         StringBuilder controlID = new StringBuilder();
@@ -226,4 +230,50 @@
     }
     
     public abstract String getDisplayName();
+    
+    /**
+     * Tell whether the given Field is uninitialized.
+     * @return <code>true</code> if the field is non-<code>null</code> and its value is <code>null</code>.
+     */ 
+    protected boolean fieldIsUninitialized( Field field )
+    {
+        try
+        {
+            return field != null && field.get( this ) == null;
+        }
+        catch ( IllegalAccessException e )
+        {
+            _log.error( "Error initializing field " + field.getName() + " in " + getDisplayName(), e );
+            return false;
+        }
+    }
+    
+    /**
+     * Initialize the given field with an instance.  Mainly useful for the error handling.
+     */ 
+    protected void initializeField( Field field, Object instance )
+    {
+        if ( instance != null )
+        {
+            if ( _log.isTraceEnabled() )
+            {
+                _log.trace( "Initializing field " + field.getName() + " in " + getDisplayName() + " with " + instance );
+            }
+            
+            try
+            {
+                field.set( this, instance );
+            }
+            catch ( IllegalArgumentException e )
+            {
+                _log.error( "Could not set field " + field.getName() + " on " + getDisplayName() +
+                            "; instance is of type " + instance.getClass().getName() + ", field type is "
+                            + field.getType().getName() );
+            }
+            catch ( IllegalAccessException e )
+            {
+                _log.error( "Error initializing field " + field.getName() + " in " + getDisplayName(), e );
+            }
+        }
+    }
 }

Added: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowPageFilter.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowPageFilter.java	Mon Sep 13 16:26:08 2004
@@ -0,0 +1,297 @@
+/*
+* 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;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Set;
+
+import org.apache.struts.util.RequestUtils;
+import org.apache.struts.action.ActionServlet;
+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;
+import org.apache.beehive.netui.pageflow.internal.JavaControlUtils;
+import org.apache.beehive.netui.pageflow.internal.InternalUtils;
+
+
+/**
+ * Base class for Servlet Filters that run before page requests.
+ */ 
+abstract class PageFlowPageFilter implements Filter
+{
+    private ServletContext _servletContext;
+    
+    private static final Logger _log = Logger.getInstance( PageFlowPageFilter.class );
+    
+    private static final String PREVENT_CACHE_ATTR = PageFlowPageFilter.class.getName() + "_preventCache";
+    
+    
+    public void init( FilterConfig filterConfig ) throws ServletException
+    {
+        _servletContext = filterConfig.getServletContext();
+    }
+    
+    protected abstract Set getValidFileExtensions();
+    
+    public void doFilter( ServletRequest request, ServletResponse response, FilterChain chain )
+            throws IOException, ServletException
+    {
+        if ( request instanceof HttpServletRequest && response instanceof HttpServletResponse )
+        {
+            HttpServletRequest httpRequest = ( HttpServletRequest ) request;
+            HttpServletResponse httpResponse = ( HttpServletResponse ) response;
+            
+            //
+            // Don't do the filter if the request is in error.
+            //
+            Object errStatusCode = request.getAttribute( "javax.servlet.error.status_code" );
+            if ( errStatusCode != null )
+            {
+                if ( _log.isDebugEnabled() )
+                {
+                    _log.debug( "Request has error status code " + errStatusCode + ".  Skipping filter." );
+                }
+                
+                chain.doFilter( request, response );        
+                return;           
+            }
+            
+            String requestURI = httpRequest.getRequestURI();
+            String extension = FileUtils.getFileExtension( requestURI );
+            
+            if ( ! getValidFileExtensions().contains( extension ) )
+            {
+                if ( _log.isDebugEnabled() )
+                {
+                    _log.debug( "Request " + requestURI + " is not an appropriate URI.  Skipping filter." );
+                }
+                
+                chain.doFilter( request, response );        
+                return;
+            }
+            
+            if ( _log.isDebugEnabled() )
+            {
+                _log.debug( "Filtering request " + requestURI );
+            }
+            
+            //
+            // If at an earlier stage in the request we determined that we should prevent caching,
+            // actually write the appropriate headers to the response now.
+            //
+            if ( request.getAttribute( PREVENT_CACHE_ATTR ) != null )
+            {
+                ServletUtils.preventCache( httpResponse );
+            }
+            
+            //
+            // Callback to the server adapter.
+            //
+            InternalUtils.getServerAdapter().beginRequest( httpRequest, httpResponse, _servletContext );
+            
+            //
+            // Initialize the ControlBeanContext in the session.
+            //
+            JavaControlUtils.initializeControlContext( httpRequest, httpResponse, _servletContext );
+            
+            try
+            {
+                ModuleConfig prevModuleConfig = RequestUtils.getRequestModuleConfig( httpRequest );
+                initializeModule( httpRequest, httpResponse );
+                
+                //
+                // Make sure that the current PageFlowController is set up for this request.
+                //
+                PageFlowController curJpf = 
+                        FlowControllerFactory.getPageFlowForRequest( httpRequest, httpResponse, _servletContext );
+                
+                //
+                // If there is no pageflow for the current Struts module, than fall back to default
+                // Struts behavior, which is *not* to allow a page request to set the current module.
+                //
+                if ( curJpf == null )
+                {
+                    InternalUtils.setCurrentModule( prevModuleConfig, request );
+                }
+                
+                
+                if ( _log.isDebugEnabled() )
+                {
+                    _log.debug( "Current PageFlowController is: " + curJpf );
+                    _log.debug( "Continuing with filter chain..." );
+                }
+                
+                runPage( curJpf, httpRequest, httpResponse, chain );
+            }
+            finally
+            {
+                //
+                // Clean up the ControlBeanContext in the session.
+                //
+                JavaControlUtils.uninitializeControlContext( httpRequest, httpResponse );
+                
+                //
+                // Callback to the server adapter.
+                //
+                InternalUtils.getServerAdapter().endRequest( httpRequest, httpResponse, _servletContext );
+            }
+        }
+        else
+        {
+            chain.doFilter( request, response );            
+        }
+    }
+    
+    private void runPage( PageFlowController curJpf, HttpServletRequest request, HttpServletResponse response,
+                          FilterChain chain )
+        throws IOException, ServletException
+    {
+        //
+        // Make sure that the pageflow's getRequest() and getResponse() will work while the page
+        // is being rendered, since methods on the pageflow may be called (through databinding
+        // or tags, or through direct reference).
+        //
+        if ( curJpf != null )
+        {
+            //
+            // We're going to bail out if there are too many concurrent requests for the same JPF.
+            // This prevents an attack that takes advantage of the fact that we synchronize requests
+            // to the same pageflow.
+            //
+            if ( curJpf.incrementRequestCount( request, response, _servletContext ) )
+            {
+                try
+                {
+                    //
+                    // Any databinding calls, indirect calls to getRequest(), etc. must be protected
+                    // against conflicts from running action methods at the same time as rendering 
+                    // the page here.  Synchronize on the JPF.
+                    //
+                    synchronized ( curJpf )
+                    {
+                        FlowController.PerRequestState newState =
+                                new FlowController.PerRequestState( request, response, null );
+                        FlowController.PerRequestState prevState = curJpf.setPerRequestState( newState );
+                        setImplicitObjects( request, response, curJpf );
+                                
+                        //
+                        // Tell the page flow that we're about to display a page so it can manage settings,
+                        // such as previous page information, if needed in advance.
+                        //
+                        curJpf.beforePage();
+                                
+                        try
+                        {
+                            chain.doFilter( request, response );
+                        }
+                        finally
+                        {
+                            curJpf.setPerRequestState( prevState );
+                        }
+                    }
+                }
+                finally
+                {
+                    curJpf.decrementRequestCount( request );
+                }
+            }
+        }
+        else
+        {
+            setImplicitObjects( request, response, null );
+            chain.doFilter( request, response );
+        }
+    }
+    
+    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
+        if ( curJpf != null )
+        {
+            FacesBackingBean fbb =
+                    FacesBackingBeanFactory.getFacesBackingBeanForRequest( request, response, _servletContext );
+            ImplicitObjectUtil.loadPageFlow( request, curJpf, fbb );
+        }
+        
+        SharedFlowController sf = FlowControllerFactory.getSharedFlowForRequest( request, response, _servletContext );
+        ImplicitObjectUtil.loadSharedFlow( request, sf );
+        
+        // @todo: need to move bundleMap creation to a BundleMapFactory
+        BundleMap bundleMap = new BundleMap( request, _servletContext, null );
+        ImplicitObjectUtil.loadBundleMap( request, bundleMap );
+    }
+    
+    private void initializeModule( HttpServletRequest request, HttpServletResponse response )
+        throws IOException, ServletException
+    {
+        //
+        // Ensure that the right Struts module is selected, for use by the tags.
+        //
+        String curModulePath = PageFlowUtils.getModulePath( request );
+        ActionServlet as = InternalUtils.getActionServlet( _servletContext );
+                
+        if ( as instanceof AutoRegisterActionServlet )
+        {
+            AutoRegisterActionServlet das = ( AutoRegisterActionServlet ) as;
+            das.ensureModuleRegistered( curModulePath, request );
+        }
+                
+        RequestUtils.selectModule( curModulePath, request, _servletContext );
+                
+        if ( RequestUtils.getRequestModuleConfig( request ) == null )
+        {
+            //
+            // If we still haven't had success in selecting the module, see if we can dynamically register one.
+            //
+            if ( as instanceof AutoRegisterActionServlet )
+            {
+                AutoRegisterActionServlet das = ( AutoRegisterActionServlet ) as;
+                das.ensureModuleSelected( curModulePath, request, response );
+            }
+        }
+    }
+    
+    /**
+     * Make sure that when this page 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
+     * to be set right before the page is rendered.
+     */ 
+    static void preventCache( HttpServletRequest request )
+    {
+        request.setAttribute( PREVENT_CACHE_ATTR, Boolean.TRUE );
+    }
+    
+    public void destroy()
+    {
+        _servletContext = null;
+    }
+}

Modified: 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/annotations/Jpf.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/annotations/Jpf.java	Mon Sep 13 16:26:08 2004
@@ -723,7 +723,13 @@
 
     @Target( ElementType.FIELD )
     @Retention( RetentionPolicy.RUNTIME )
-    public @interface SharedFlowField
+            public @interface SharedFlowField
+    {
+    }
+
+    @Target( ElementType.FIELD )
+    @Retention( RetentionPolicy.RUNTIME )
+    public @interface PageFlowField
     {
     }
     

Added: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/CachedFacesBackingInfo.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/CachedFacesBackingInfo.java	Mon Sep 13 16:26:08 2004
@@ -0,0 +1,75 @@
+/*
+* 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 org.apache.beehive.netui.pageflow.PageFlowConstants;
+import org.apache.beehive.netui.pageflow.annotations.Jpf;
+
+import java.lang.reflect.Field;
+
+
+/**
+ * Information that is cached per pageflow class.
+ * 
+ * @exclude
+ */ 
+public class CachedFacesBackingInfo
+{
+    /**
+     * The SharedFlowController-initialized member field -- may or may not be present.
+     */ 
+    private Field _sharedFlowMemberField;
+    
+    /**
+     * The PageFlowController-initialized member field -- may or may not be present.
+     */ 
+    private Field _pageFlowMemberField;
+    
+    
+    public CachedFacesBackingInfo( Class pageFlowClass )
+    {
+        Field[] fields = pageFlowClass.getDeclaredFields();
+        
+        for ( int i = 0; i < fields.length; i++ )
+        {
+            Field field = fields[i];
+            
+            if ( field.getAnnotation( Jpf.SharedFlowField.class ) != null )
+            {
+                _sharedFlowMemberField = field;
+                _sharedFlowMemberField.setAccessible( true );
+            }
+            else if ( field.getAnnotation( Jpf.PageFlowField.class ) != null )
+            {
+                _pageFlowMemberField = field;
+                _pageFlowMemberField.setAccessible( true );
+            }
+        }
+    }
+    
+    public Field getSharedFlowMemberField()
+    {
+        return _sharedFlowMemberField;
+    }
+
+    public Field getPageFlowMemberField()
+    {
+        return _pageFlowMemberField;
+    }
+}
+

Modified: incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/ServletUtils.java
==============================================================================
--- incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/ServletUtils.java	(original)
+++ incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/ServletUtils.java	Mon Sep 13 16:26:08 2004
@@ -111,4 +111,19 @@
         assert lastSlash < uri.length() - 1 : "URI must not end with a slash: " + uri;
         return uri.substring( lastSlash + 1 );
     }
+ 
+    /**
+     * Get the directory path of the given URI.
+     *
+     * @param uri the URI from which to get the directory path.
+     * @return a String containing everything before the last slash of the given URI.
+     */
+    public static String getDirName( String uri )
+    {
+        int lastSlash = uri.lastIndexOf( '/' );
+        assert lastSlash != -1 : uri;
+        assert uri.length() > 1 : uri;
+        assert lastSlash < uri.length() - 1 : "URI must not end with a slash: " + uri;
+        return uri.substring( 0, lastSlash );
+    }
 }

Modified: incubator/beehive/trunk/netui/src/webapp-template/dd/generic/web.xml
==============================================================================
--- incubator/beehive/trunk/netui/src/webapp-template/dd/generic/web.xml	(original)
+++ incubator/beehive/trunk/netui/src/webapp-template/dd/generic/web.xml	Mon Sep 13 16:26:08 2004
@@ -12,11 +12,37 @@
         <filter-class>org.apache.beehive.netui.pageflow.PageFlowJspFilter</filter-class>
     </filter>
 
+    <filter>
+        <filter-name>PageFlowFacesFilter</filter-name>
+        <filter-class>org.apache.beehive.netui.pageflow.PageFlowFacesFilter</filter-class>
+    </filter>
+
     <filter-mapping>
         <filter-name>PageFlowJspFilter</filter-name>
         <url-pattern>*.jsp</url-pattern>
+        <dispatcher>FORWARD</dispatcher>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
+    </filter-mapping>
+
+    <filter-mapping>
+        <filter-name>PageFlowJspFilter</filter-name>
         <url-pattern>*.jspx</url-pattern>
+        <dispatcher>FORWARD</dispatcher>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
+    </filter-mapping>
+
+    <filter-mapping>
+        <filter-name>PageFlowFacesFilter</filter-name>
         <url-pattern>*.faces</url-pattern>
+        <dispatcher>FORWARD</dispatcher>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
+    </filter-mapping>
+
+    <filter-mapping>
+        <filter-name>PageFlowFacesFilter</filter-name>
         <url-pattern>*.jsf</url-pattern>
         <dispatcher>FORWARD</dispatcher>
         <dispatcher>REQUEST</dispatcher>

Modified: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/web.xml
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/web.xml	(original)
+++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/web.xml	Mon Sep 13 16:26:08 2004
@@ -56,17 +56,46 @@
     <filter-class>org.apache.beehive.netui.pageflow.PageFlowJspFilter</filter-class>
   </filter>
 
+  <filter>
+      <filter-name>PageFlowFacesFilter</filter-name>
+      <filter-class>org.apache.beehive.netui.pageflow.PageFlowFacesFilter</filter-class>
+  </filter>
+
   <filter-mapping>
     <filter-name>TestRecorderFilter</filter-name>
     <url-pattern>/*</url-pattern>
   </filter-mapping>
 
   <filter-mapping>
-    <filter-name>PageFlowJspFilter</filter-name>
-    <url-pattern>*.jsp</url-pattern>
-    <dispatcher>FORWARD</dispatcher>
-    <dispatcher>REQUEST</dispatcher>
-    <dispatcher>INCLUDE</dispatcher>
+      <filter-name>PageFlowJspFilter</filter-name>
+      <url-pattern>*.jsp</url-pattern>
+      <dispatcher>FORWARD</dispatcher>
+      <dispatcher>REQUEST</dispatcher>
+      <dispatcher>INCLUDE</dispatcher>
+  </filter-mapping>
+
+  <filter-mapping>
+      <filter-name>PageFlowJspFilter</filter-name>
+      <url-pattern>*.jspx</url-pattern>
+      <dispatcher>FORWARD</dispatcher>
+      <dispatcher>REQUEST</dispatcher>
+      <dispatcher>INCLUDE</dispatcher>
+  </filter-mapping>
+
+  <filter-mapping>
+      <filter-name>PageFlowFacesFilter</filter-name>
+      <url-pattern>*.faces</url-pattern>
+      <dispatcher>FORWARD</dispatcher>
+      <dispatcher>REQUEST</dispatcher>
+      <dispatcher>INCLUDE</dispatcher>
+  </filter-mapping>
+
+  <filter-mapping>
+      <filter-name>PageFlowFacesFilter</filter-name>
+      <url-pattern>*.jsf</url-pattern>
+      <dispatcher>FORWARD</dispatcher>
+      <dispatcher>REQUEST</dispatcher>
+      <dispatcher>INCLUDE</dispatcher>
   </filter-mapping>
 
     <!--

Modified: incubator/beehive/trunk/netui/test/webapps/jsf/jsfWeb/WEB-INF/web.xml
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/jsf/jsfWeb/WEB-INF/web.xml	(original)
+++ incubator/beehive/trunk/netui/test/webapps/jsf/jsfWeb/WEB-INF/web.xml	Mon Sep 13 16:26:08 2004
@@ -56,6 +56,11 @@
     <filter-class>org.apache.beehive.netui.pageflow.PageFlowJspFilter</filter-class>
   </filter>
 
+  <filter>
+      <filter-name>PageFlowFacesFilter</filter-name>
+      <filter-class>org.apache.beehive.netui.pageflow.PageFlowFacesFilter</filter-class>
+  </filter>
+
   <filter-mapping>
     <filter-name>TestRecorderFilter</filter-name>
     <url-pattern>/*</url-pattern>
@@ -64,7 +69,30 @@
   <filter-mapping>
       <filter-name>PageFlowJspFilter</filter-name>
       <url-pattern>*.jsp</url-pattern>
+      <dispatcher>FORWARD</dispatcher>
+      <dispatcher>REQUEST</dispatcher>
+      <dispatcher>INCLUDE</dispatcher>
+  </filter-mapping>
+
+  <filter-mapping>
+      <filter-name>PageFlowJspFilter</filter-name>
+      <url-pattern>*.jspx</url-pattern>
+      <dispatcher>FORWARD</dispatcher>
+      <dispatcher>REQUEST</dispatcher>
+      <dispatcher>INCLUDE</dispatcher>
+  </filter-mapping>
+
+  <filter-mapping>
+      <filter-name>PageFlowFacesFilter</filter-name>
       <url-pattern>*.faces</url-pattern>
+      <dispatcher>FORWARD</dispatcher>
+      <dispatcher>REQUEST</dispatcher>
+      <dispatcher>INCLUDE</dispatcher>
+  </filter-mapping>
+
+  <filter-mapping>
+      <filter-name>PageFlowFacesFilter</filter-name>
+      <url-pattern>*.jsf</url-pattern>
       <dispatcher>FORWARD</dispatcher>
       <dispatcher>REQUEST</dispatcher>
       <dispatcher>INCLUDE</dispatcher>

Added: incubator/beehive/trunk/netui/test/webapps/jsf/jsfWeb/initMemberFields/InitMemberFieldsController.jpf
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/netui/test/webapps/jsf/jsfWeb/initMemberFields/InitMemberFieldsController.jpf	Mon Sep 13 16:26:08 2004
@@ -0,0 +1,34 @@
+package initMemberFields;
+
+import javax.servlet.http.HttpSession;
+import org.apache.beehive.netui.pageflow.PageFlowController;
+import org.apache.beehive.netui.pageflow.Forward;
+import org.apache.beehive.netui.pageflow.annotations.Jpf;
+
+@Jpf.Controller
+public class InitMemberFieldsController extends PageFlowController
+{
+    @Jpf.Action(forwards = {
+        @Jpf.Forward(name = "success",
+                     path = "page1.faces")
+    })
+    protected Forward begin()
+    {
+        return new Forward("success");
+    }
+
+
+    /**
+     * Callback that is invoked when this controller instance is created.
+     */
+    protected void onCreate()
+    {
+    }
+
+    /**
+     * Callback that is invoked when this controller instance is destroyed.
+     */
+    protected void onDestroy(HttpSession session)
+    {
+    }
+}

Added: incubator/beehive/trunk/netui/test/webapps/jsf/jsfWeb/initMemberFields/InitMemberFieldsSharedFlow.jpfs
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/netui/test/webapps/jsf/jsfWeb/initMemberFields/InitMemberFieldsSharedFlow.jpfs	Mon Sep 13 16:26:08 2004
@@ -0,0 +1,11 @@
+package initMemberFields;
+
+import javax.servlet.http.HttpSession;
+import org.apache.beehive.netui.pageflow.SharedFlowController;
+import org.apache.beehive.netui.pageflow.Forward;
+import org.apache.beehive.netui.pageflow.annotations.Jpf;
+
+@Jpf.Controller
+public class InitMemberFieldsSharedFlow extends SharedFlowController
+{
+}

Added: incubator/beehive/trunk/netui/test/webapps/jsf/jsfWeb/initMemberFields/page1.jsfb
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/netui/test/webapps/jsf/jsfWeb/initMemberFields/page1.jsfb	Mon Sep 13 16:26:08 2004
@@ -0,0 +1,49 @@
+package initMemberFields;
+
+import org.apache.beehive.netui.pageflow.FacesBackingBean;
+import org.apache.beehive.netui.pageflow.annotations.Jpf;
+import javax.faces.component.UIOutput;
+
+
+/**
+ * This is the default Faces Backing file for a JSF Page.
+ */
+@Jpf.FacesBacking
+public class page1 extends FacesBackingBean
+{
+    @Jpf.SharedFlowField
+    InitMemberFieldsSharedFlow _sharedFlow;
+
+    @Jpf.PageFlowField
+    InitMemberFieldsController _pageFlow;
+
+    private UIOutput _sharedFlowField = new UIOutput();
+    private UIOutput _pageFlowField = new UIOutput();
+
+    public UIOutput getSharedFlowField()
+    {
+        return _sharedFlowField;
+    }
+
+    public void setSharedFlowField( UIOutput sharedFlowField )
+    {
+        _sharedFlowField = sharedFlowField;
+    }
+
+    public UIOutput getPageFlowField()
+    {
+        return _pageFlowField;
+    }
+
+    public void setPageFlowField( UIOutput pageFlowField )
+    {
+        _pageFlowField = pageFlowField;
+    }
+
+    public String checkFields()
+    {
+        _sharedFlowField.setValue( _sharedFlow.getClass().getName() );
+        _pageFlowField.setValue( _pageFlow.getClass().getName() );
+        return null;
+    }
+}
\ No newline at end of file

Added: incubator/beehive/trunk/netui/test/webapps/jsf/jsfWeb/initMemberFields/page1.jsp
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/netui/test/webapps/jsf/jsfWeb/initMemberFields/page1.jsp	Mon Sep 13 16:26:08 2004
@@ -0,0 +1,22 @@
+<%@ page language="java" contentType="text/html;charset=UTF-8"%>
+<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
+<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
+
+<html>
+    <head>
+    </head>
+    <body>
+        <f:view>
+            <h:form>
+                <h:commandButton action="#{backing.checkFields}" value="check fields"/>
+                <br/>
+                page flow is of type: <h:outputText binding="#{backing.pageFlowField}"/>
+                <br/>
+                shared flow is of type: <h:outputText binding="#{backing.sharedFlowField}"/>
+                <br/>
+            </h:form>
+        </f:view>
+    </body>
+</html>
+
+  
\ No newline at end of file

Modified: incubator/beehive/trunk/netui/test/webapps/jsf/testRecorder/config/testRecorder-tests.xml
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/jsf/testRecorder/config/testRecorder-tests.xml	(original)
+++ incubator/beehive/trunk/netui/test/webapps/jsf/testRecorder/config/testRecorder-tests.xml	Mon Sep 13 16:26:08 2004
@@ -84,6 +84,14 @@
             </categories>
         </test>
         <test>
+            <name>InitMemberFields</name>
+            <description>Test of initialization of backing class fields marked with @Jpf.SharedFlowField and @Jpf.PageFlowField.</description>
+            <webapp>jsfWeb</webapp>
+            <categories>
+                <category>drt</category>
+            </categories>
+        </test>
+        <test>
             <name>JpfFaces</name>
             <description>Test of basic JSF / page flow integration, including raising actions and passing forms from JSF pages and backing files.</description>
             <webapp>jsfWeb</webapp>

Added: incubator/beehive/trunk/netui/test/webapps/jsf/testRecorder/tests/InitMemberFields.xml
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/netui/test/webapps/jsf/testRecorder/tests/InitMemberFields.xml	Mon Sep 13 16:26:08 2004
@@ -0,0 +1,194 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ses:recorderSession xmlns:ses="http://beehive.apache.org/netui/tools/testrecorder/2004/session">
+   <ses:sessionName>InitMemberFields</ses:sessionName>
+   <ses:tester>rich</ses:tester>
+   <ses:startDate>13 Sep 2004, 01:26:16.603 PM MDT</ses:startDate>
+   <ses:description>Test of initialization of backing class fields marked with @Jpf.SharedFlowField and @Jpf.PageFlowField.</ses:description>
+   <ses:tests>
+      <ses:test>
+         <ses:testNumber>1</ses:testNumber>
+         <ses:request>
+            <ses:protocol>HTTP</ses:protocol>
+            <ses:protocolVersion>1.1</ses:protocolVersion>
+            <ses:host>localhost</ses:host>
+            <ses:port>8080</ses:port>
+            <ses:uri>/jsfWeb/initMemberFields/InitMemberFieldsController.jpf</ses:uri>
+            <ses:method>GET</ses:method>
+            <ses:parameters/>
+            <ses:cookies>
+               <ses:cookie>
+                  <ses:name>JSESSIONID</ses:name>
+                  <ses:value>2E870FD12DC0AAF6A7E321DF6ED38D1A</ses:value>
+               </ses:cookie>
+               <ses:cookie>
+                  <ses:name>JSESSIONID</ses:name>
+                  <ses:value>BFLlWEVV1GsFuJ07Xu18zQyqjGFQEnhf7q1vgAzujKQGW0Zv5Asl!-900177817</ses:value>
+               </ses:cookie>
+            </ses:cookies>
+            <ses:headers>
+               <ses:header>
+                  <ses:name>accept</ses:name>
+                  <ses:value>text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>accept-charset</ses:name>
+                  <ses:value>ISO-8859-1,utf-8;q=0.7,*;q=0.7</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>accept-encoding</ses:name>
+                  <ses:value>gzip,deflate</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>accept-language</ses:name>
+                  <ses:value>en-us,en;q=0.5</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>connection</ses:name>
+                  <ses:value>keep-alive</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>cookie</ses:name>
+                  <ses:value>JSESSIONID=2E870FD12DC0AAF6A7E321DF6ED38D1A; JSESSIONID=BFLlWEVV1GsFuJ07Xu18zQyqjGFQEnhf7q1vgAzujKQGW0Zv5Asl!-900177817</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>host</ses:name>
+                  <ses:value>localhost:8080</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>keep-alive</ses:name>
+                  <ses:value>300</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>user-agent</ses:name>
+                  <ses:value>Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040803 Firefox/0.9.3</ses:value>
+               </ses:header>
+            </ses:headers>
+         </ses:request>
+         <ses:response>
+            <ses:statusCode>200</ses:statusCode>
+            <ses:reason/>
+            <ses:responseBody><![CDATA[<html>
+    <head>
+    </head>
+    <body>
+        
+            <form id="_id0" method="post" action="/jsfWeb/initMemberFields/page1.faces" enctype="application/x-www-form-urlencoded">
+
+                <input type="submit" name="_id0:_id1" value="check fields" />
+                <br/>
+                page flow is of type: 
+                <br/>
+                shared flow is of type: 
+                <br/>
+            <input type="hidden" name="_id0" value="_id0" /></form>
+        
+    </body>
+</html>]]></ses:responseBody>
+         </ses:response>
+      </ses:test>
+      <ses:test>
+         <ses:testNumber>2</ses:testNumber>
+         <ses:request>
+            <ses:protocol>HTTP</ses:protocol>
+            <ses:protocolVersion>1.1</ses:protocolVersion>
+            <ses:host>localhost</ses:host>
+            <ses:port>8080</ses:port>
+            <ses:uri>/jsfWeb/initMemberFields/page1.faces</ses:uri>
+            <ses:method>POST</ses:method>
+            <ses:parameters>
+               <ses:parameter>
+                  <ses:name>_id0</ses:name>
+                  <ses:value>_id0</ses:value>
+               </ses:parameter>
+               <ses:parameter>
+                  <ses:name>_id0:_id1</ses:name>
+                  <ses:value>check fields</ses:value>
+               </ses:parameter>
+            </ses:parameters>
+            <ses:cookies>
+               <ses:cookie>
+                  <ses:name>JSESSIONID</ses:name>
+                  <ses:value>2E870FD12DC0AAF6A7E321DF6ED38D1A</ses:value>
+               </ses:cookie>
+               <ses:cookie>
+                  <ses:name>JSESSIONID</ses:name>
+                  <ses:value>BFLlWEVV1GsFuJ07Xu18zQyqjGFQEnhf7q1vgAzujKQGW0Zv5Asl!-900177817</ses:value>
+               </ses:cookie>
+            </ses:cookies>
+            <ses:headers>
+               <ses:header>
+                  <ses:name>accept</ses:name>
+                  <ses:value>text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>accept-charset</ses:name>
+                  <ses:value>ISO-8859-1,utf-8;q=0.7,*;q=0.7</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>accept-encoding</ses:name>
+                  <ses:value>gzip,deflate</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>accept-language</ses:name>
+                  <ses:value>en-us,en;q=0.5</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>connection</ses:name>
+                  <ses:value>keep-alive</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>content-length</ses:name>
+                  <ses:value>34</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>content-type</ses:name>
+                  <ses:value>application/x-www-form-urlencoded</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>cookie</ses:name>
+                  <ses:value>JSESSIONID=2E870FD12DC0AAF6A7E321DF6ED38D1A; JSESSIONID=BFLlWEVV1GsFuJ07Xu18zQyqjGFQEnhf7q1vgAzujKQGW0Zv5Asl!-900177817</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>host</ses:name>
+                  <ses:value>localhost:8080</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>keep-alive</ses:name>
+                  <ses:value>300</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>referer</ses:name>
+                  <ses:value>http://localhost:8080/jsfWeb/initMemberFields/InitMemberFieldsController.jpf</ses:value>
+               </ses:header>
+               <ses:header>
+                  <ses:name>user-agent</ses:name>
+                  <ses:value>Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040803 Firefox/0.9.3</ses:value>
+               </ses:header>
+            </ses:headers>
+         </ses:request>
+         <ses:response>
+            <ses:statusCode>200</ses:statusCode>
+            <ses:reason/>
+            <ses:responseBody><![CDATA[<html>
+    <head>
+    </head>
+    <body>
+        
+            <form id="_id0" method="post" action="/jsfWeb/initMemberFields/page1.faces" enctype="application/x-www-form-urlencoded">
+
+                <input type="submit" name="_id0:_id1" value="check fields" />
+                <br/>
+                page flow is of type: initMemberFields.InitMemberFieldsController
+                <br/>
+                shared flow is of type: initMemberFields.InitMemberFieldsSharedFlow
+                <br/>
+            <input type="hidden" name="_id0" value="_id0" /></form>
+        
+    </body>
+</html>]]></ses:responseBody>
+         </ses:response>
+      </ses:test>
+   </ses:tests>
+   <ses:endDate>13 Sep 2004, 01:26:30.082 PM MDT</ses:endDate>
+   <ses:testCount>2</ses:testCount>
+</ses:recorderSession>

Modified: incubator/beehive/trunk/netui/test/webapps/testRecorder-test/testRecorder-test/WEB-INF/web.xml
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/testRecorder-test/testRecorder-test/WEB-INF/web.xml	(original)
+++ incubator/beehive/trunk/netui/test/webapps/testRecorder-test/testRecorder-test/WEB-INF/web.xml	Mon Sep 13 16:26:08 2004
@@ -28,6 +28,11 @@
         <filter-class>org.apache.beehive.netui.pageflow.PageFlowJspFilter</filter-class>
     </filter>
 
+    <filter>
+        <filter-name>PageFlowFacesFilter</filter-name>
+        <filter-class>org.apache.beehive.netui.pageflow.PageFlowFacesFilter</filter-class>
+    </filter>
+
     <!-- Test Recorder Filter -->
     <filter>
         <filter-name>TestRecorderFilter</filter-name>
@@ -39,13 +44,40 @@
     </filter>
 
     <filter-mapping>
+        <filter-name>TestRecorderFilter</filter-name>
+        <url-pattern>/*</url-pattern>
+    </filter-mapping>
+
+    <filter-mapping>
         <filter-name>PageFlowJspFilter</filter-name>
         <url-pattern>*.jsp</url-pattern>
+        <dispatcher>FORWARD</dispatcher>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
     </filter-mapping>
 
     <filter-mapping>
-        <filter-name>TestRecorderFilter</filter-name>
-        <url-pattern>/*</url-pattern>
+        <filter-name>PageFlowJspFilter</filter-name>
+        <url-pattern>*.jspx</url-pattern>
+        <dispatcher>FORWARD</dispatcher>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
+    </filter-mapping>
+
+    <filter-mapping>
+        <filter-name>PageFlowFacesFilter</filter-name>
+        <url-pattern>*.faces</url-pattern>
+        <dispatcher>FORWARD</dispatcher>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
+    </filter-mapping>
+
+    <filter-mapping>
+        <filter-name>PageFlowFacesFilter</filter-name>
+        <url-pattern>*.jsf</url-pattern>
+        <dispatcher>FORWARD</dispatcher>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
     </filter-mapping>
 
     <!-- Standard Action Servlet Configuration (with debugging) -->

Modified: incubator/beehive/trunk/netui/test/webapps/urlTemplates/urlTemplates/WEB-INF/web.xml
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/urlTemplates/urlTemplates/WEB-INF/web.xml	(original)
+++ incubator/beehive/trunk/netui/test/webapps/urlTemplates/urlTemplates/WEB-INF/web.xml	Mon Sep 13 16:26:08 2004
@@ -27,6 +27,11 @@
         <filter-class>org.apache.beehive.netui.pageflow.PageFlowJspFilter</filter-class>
     </filter>
 
+    <filter>
+        <filter-name>PageFlowFacesFilter</filter-name>
+        <filter-class>org.apache.beehive.netui.pageflow.PageFlowFacesFilter</filter-class>
+    </filter>
+
     <filter-mapping>
         <filter-name>TestRecorderFilter</filter-name>
         <url-pattern>/*</url-pattern>
@@ -35,6 +40,33 @@
     <filter-mapping>
         <filter-name>PageFlowJspFilter</filter-name>
         <url-pattern>*.jsp</url-pattern>
+        <dispatcher>FORWARD</dispatcher>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
+    </filter-mapping>
+
+    <filter-mapping>
+        <filter-name>PageFlowJspFilter</filter-name>
+        <url-pattern>*.jspx</url-pattern>
+        <dispatcher>FORWARD</dispatcher>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
+    </filter-mapping>
+
+    <filter-mapping>
+        <filter-name>PageFlowFacesFilter</filter-name>
+        <url-pattern>*.faces</url-pattern>
+        <dispatcher>FORWARD</dispatcher>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
+    </filter-mapping>
+
+    <filter-mapping>
+        <filter-name>PageFlowFacesFilter</filter-name>
+        <url-pattern>*.jsf</url-pattern>
+        <dispatcher>FORWARD</dispatcher>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
     </filter-mapping>
 
     <servlet>

Modified: incubator/beehive/trunk/netui/test/webapps/webappBuild-test/webappBuild-test/WEB-INF/web.xml
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/webappBuild-test/webappBuild-test/WEB-INF/web.xml	(original)
+++ incubator/beehive/trunk/netui/test/webapps/webappBuild-test/webappBuild-test/WEB-INF/web.xml	Mon Sep 13 16:26:08 2004
@@ -28,9 +28,41 @@
         <filter-class>org.apache.beehive.netui.pageflow.PageFlowJspFilter</filter-class>
     </filter>
 
+    <filter>
+        <filter-name>PageFlowFacesFilter</filter-name>
+        <filter-class>org.apache.beehive.netui.pageflow.PageFlowFacesFilter</filter-class>
+    </filter>
+
     <filter-mapping>
         <filter-name>PageFlowJspFilter</filter-name>
         <url-pattern>*.jsp</url-pattern>
+        <dispatcher>FORWARD</dispatcher>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
+    </filter-mapping>
+
+    <filter-mapping>
+        <filter-name>PageFlowJspFilter</filter-name>
+        <url-pattern>*.jspx</url-pattern>
+        <dispatcher>FORWARD</dispatcher>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
+    </filter-mapping>
+
+    <filter-mapping>
+        <filter-name>PageFlowFacesFilter</filter-name>
+        <url-pattern>*.faces</url-pattern>
+        <dispatcher>FORWARD</dispatcher>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
+    </filter-mapping>
+
+    <filter-mapping>
+        <filter-name>PageFlowFacesFilter</filter-name>
+        <url-pattern>*.jsf</url-pattern>
+        <dispatcher>FORWARD</dispatcher>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
     </filter-mapping>
 
     <!-- Standard Action Servlet Configuration (with debugging) -->

Mime
View raw message