You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ri...@apache.org on 2004/12/01 08:09:50 UTC

svn commit: r109309 - in incubator/beehive/trunk/netui: src/compiler/org/apache/beehive/netui/compiler src/pageflow/org/apache/beehive/netui/pageflow src/pageflow/org/apache/beehive/netui/pageflow/internal src/pageflow/org/apache/beehive/netui/pageflow/util src/scoping/org/apache/beehive/netui/pageflow/scoping src/scoping/org/apache/beehive/netui/pageflow/scoping/internal src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/model src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/rendering/impl src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/util src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid src/tags-html/org/apache/beehive/netui/tags src/tags-html/org/apache/beehive/netui/tags/html src/tags-html/org/apache/beehive/netui/tags/tree src/util src/util/org/apache/beehive/netui/util src/util/org/apache/beehive/netui/util/cache test/webapps/drt/coreWeb/WEB-INF/src/mockportal

Author: rich
Date: Tue Nov 30 23:09:49 2004
New Revision: 109309

URL: http://svn.apache.org/viewcvs?view=rev&rev=109309
Log:
This is a contribution from Carlin Rogers:

    "- Implemented a new URLRewriterService and URLRewriter.
    The framework was extended to allow for chaining of
    registered URLRewriters. The old URLRewriterService,
    DefaultURLRewriter and URLRewriter were deprecated and
    no use the new URLRewriterService. If an implementation
    uses the deprecated URLRewriterService to register an
    old URLRewriter it will be handled with a wrapper. I
    still need to work on the Template URL rewriting.

    - Implemented MutableURI to be used in the URLRewriter
    implementations to reduce some of the String parsing.

    - Moved org.apache.beehive.netui.pageflow.util.PageflowTagUtils
    to the tags-html module,
    org.apache.beehive.netui.tags.PageFlowTagUtils and consolidated
    code for preparing and rewriting an action or resource URL.

    - Update NetUI tag code to use the new PageFlowTagUtils
    methods. Also added some exception handling and a new
    error messages.

    - Separated the initialization and management of the ServerAdapter
    from the ContextCache to a ServerAdapterManager class.

    - Modified MockPortal test so that the scoped request for each
    portlet does not expose the outer request attributes. This is
    the desired state, however, this breaks the test because the
    PageFlowJspFilter isn't running on the include. I will log a
    bug in JIRA.
        [Note from Rich: I made some modifications to address this issue as part of the checkin; will describe it in an email to the dev list.]

    - Minor clean up such as removing unused import statements
    and removing the ServletContextCache class."

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


Added:
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultURLRewriter.java   (contents, props changed)
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ServerAdapterManager.java   (contents, props changed)
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/OldURLRewriterWrapper.java   (contents, props changed)
   incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/PageFlowTagUtils.java
      - copied, changed from r109234, incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/PageflowTagUtils.java
Modified:
   incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/diagnostics.properties
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBean.java
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBeanFactory.java
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/Forward.java
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.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/PageFlowPageFilter.java
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowStack.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/SharedFlowController.java
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ContextCache.java
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultLoginHandler.java
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultReloadableClassHandler.java
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/JavaControlUtils.java
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/DefaultURLRewriter.java
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/PageflowTagUtils.java
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/TemplateHelper.java
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriter.java
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriterService.java
   incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedRequest.java
   incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedServletUtils.java
   incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/internal/ScopedRequestImpl.java
   incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/model/PagerModel.java
   incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/rendering/impl/AbstractPagerRenderer.java
   incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/rendering/impl/FirstPreviousNextLastPagerRenderer.java
   incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/rendering/impl/PreviousNextPagerRenderer.java
   incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/util/JspUtil.java
   incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/AnchorColumn.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/BindingUpdateErrors.java
   incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Button.java
   incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Exceptions.java
   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/Image.java
   incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageAnchor.java
   incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageButton.java
   incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RewriteURL.java
   incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java
   incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/TreeItem.java
   incubator/beehive/trunk/netui/src/util/build.xml
   incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/cache/ServletContextCache.java
   incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties
   incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/mockportal/MockPortalUrlRewriter.java
   incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/mockportal/MockPortletTag.java

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=109309&p1=incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/diagnostics.properties&r1=109308&p2=incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/diagnostics.properties&r2=109309
==============================================================================
--- 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	Tue Nov 30 23:09:49 2004
@@ -105,7 +105,7 @@
 error.invalid-java-identifier-start = The character ''{0}'' may not be used as the first character of this identifier.
 error.invalid-java-identifier-part = The character ''{0}'' may not be used in this identifier.
 error.array-type-not-allowed = This value may not be an array type.
-error.primitive-type-not-allowed = This value may not be an primitive type.
+error.primitive-type-not-allowed = This value may not be a primitive type.
 error.void-type-not-allowed = This value may not be the void type.
 error.must-be-primitive-type = This value must be a primitive Class, e.g. int.class.
 error.invalid-type = This type is not allowed here.

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBean.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBean.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBean.java&r1=109308&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBean.java&r2=109309
==============================================================================
--- 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	Tue Nov 30 23:09:49 2004
@@ -20,13 +20,12 @@
 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.internal.ContextCache;
+import org.apache.beehive.netui.pageflow.internal.ServerAdapterManager;
 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.http.HttpSession;
 import javax.servlet.ServletContext;
 import java.util.Map;
 import java.util.Collections;
@@ -58,7 +57,7 @@
         String attr =
                 ScopedServletUtils.getScopedSessionAttrName( InternalConstants.FACES_BACKING_ATTR, unwrappedRequest );
         ServletContext servletContext = InternalUtils.getServletContext( request );
-        ContextCache.get( servletContext ).getServerAdapter().ensureFailover( attr, this, unwrappedRequest );
+        ServerAdapterManager.getServerAdapter( servletContext ).ensureFailover( attr, this, unwrappedRequest );
     }
 
     public String getDisplayName()

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBeanFactory.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBeanFactory.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBeanFactory.java&r1=109308&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBeanFactory.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBeanFactory.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBeanFactory.java	Tue Nov 30 23:09:49 2004
@@ -20,7 +20,6 @@
 import static org.apache.beehive.netui.pageflow.internal.InternalConstants.FACES_BACKING_ATTR;
 import org.apache.beehive.netui.pageflow.internal.InternalUtils;
 import org.apache.beehive.netui.pageflow.internal.ContextCache;
-import org.apache.beehive.netui.pageflow.internal.InternalConstants;
 import org.apache.beehive.netui.pageflow.annotations.Jpf;
 import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
 import org.apache.beehive.netui.util.FileUtils;

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/Forward.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/Forward.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/Forward.java&r1=109308&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/Forward.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/Forward.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/Forward.java	Tue Nov 30 23:09:49 2004
@@ -37,6 +37,7 @@
 import org.apache.beehive.netui.pageflow.config.PageFlowActionForward;
 import org.apache.beehive.netui.pageflow.internal.InternalUtils;
 import org.apache.beehive.netui.pageflow.internal.ContextCache;
+import org.apache.beehive.netui.pageflow.internal.ServerAdapterManager;
 import org.apache.beehive.netui.pageflow.handler.ReloadableClassHandler;
 
 
@@ -577,7 +578,7 @@
     {
         PageFlowActionForward.ActionOutput[] actionOutputs = fc.getActionOutputs();
         boolean isInProductionMode =
-                ContextCache.get( _servletContext ).getServerAdapter().isInProductionMode();
+                ServerAdapterManager.getServerAdapter( _servletContext ).isInProductionMode();
             
         for ( int i = 0; i < actionOutputs.length; ++i )
         {

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java&r1=109308&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java	Tue Nov 30 23:09:49 2004
@@ -20,9 +20,10 @@
 //java imports
 
 //internal imports
-import org.apache.beehive.netui.pageflow.util.UrlTemplateDescriptor;
 import org.apache.beehive.netui.pageflow.internal.ContextCache;
 import org.apache.beehive.netui.pageflow.internal.InternalConstants;
+import org.apache.beehive.netui.pageflow.internal.ServerAdapterManager;
+import org.apache.beehive.netui.pageflow.util.UrlTemplateDescriptor;
 import org.apache.beehive.netui.util.config.ConfigUtil;
 import org.apache.beehive.netui.util.config.ConfigInitializationException;
 import org.apache.beehive.netui.util.logging.Logger;
@@ -95,6 +96,7 @@
         }
         
         ContextCache.init( servletContext );
+        ServerAdapterManager.init( servletContext );
         UrlTemplateDescriptor.getInstance().load( servletContext );
     }
 }

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=109309&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowController.java&r1=109308&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowController.java&r2=109309
==============================================================================
--- 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	Tue Nov 30 23:09:49 2004
@@ -36,7 +36,7 @@
 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.internal.ContextCache;
+import org.apache.beehive.netui.pageflow.internal.ServerAdapterManager;
 import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
 
 import static org.apache.beehive.netui.pageflow.internal.InternalConstants.*;
@@ -204,7 +204,7 @@
         if ( request.getAttribute( DELETING_PAGEFLOW_ATTR ) != this && request.getSession( false ) != null )
         {
             HttpServletRequest unwrappedRequest = PageFlowUtils.unwrapMultipart( request );
-            ServerAdapter serverAdapter = ContextCache.get( getServletContext() ).getServerAdapter();
+            ServerAdapter serverAdapter = ServerAdapterManager.getServerAdapter( getServletContext() );
         
             //
             // If this is a long-lived page flow, there are two attributes to deal with.

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowPageFilter.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowPageFilter.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowPageFilter.java&r1=109308&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowPageFilter.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowPageFilter.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowPageFilter.java	Tue Nov 30 23:09:49 2004
@@ -35,15 +35,17 @@
 import org.apache.struts.config.ModuleConfig;
 import org.apache.struts.Globals;
 
+import org.apache.beehive.netui.core.urls.URLRewriterService;
 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.DefaultURLRewriter;
 import org.apache.beehive.netui.pageflow.internal.JavaControlUtils;
 import org.apache.beehive.netui.pageflow.internal.InternalUtils;
 import org.apache.beehive.netui.pageflow.internal.InternalConstants;
-import org.apache.beehive.netui.pageflow.internal.ContextCache;
+import org.apache.beehive.netui.pageflow.internal.ServerAdapterManager;
 
 
 /**
@@ -52,6 +54,7 @@
 public abstract class PageFlowPageFilter implements Filter
 {
     private ServletContext _servletContext;
+    private ServerAdapter _serverAdapter;
     
     private static final Logger _log = Logger.getInstance( PageFlowPageFilter.class );
     
@@ -65,6 +68,7 @@
     public void init( FilterConfig filterConfig ) throws ServletException
     {
         _servletContext = filterConfig.getServletContext();
+        _serverAdapter = ServerAdapterManager.getServerAdapter( _servletContext );
     }
     
     protected abstract Set getValidFileExtensions();
@@ -121,16 +125,26 @@
             }
             
             //
+            // Initialize the ServletContext in the request.  Often, we need access to the ServletContext when we only
+            // have a ServletRequest.
+            //
+            InternalUtils.setServletContext( httpRequest, _servletContext );
+            
+            //
             // Callback to the server adapter.
             //
-            ServerAdapter serverAdapter = ContextCache.get( _servletContext ).getServerAdapter();
-            serverAdapter.beginRequest( httpRequest, httpResponse );
+            _serverAdapter.beginRequest( httpRequest, httpResponse );
             
             //
             // Initialize the ControlBeanContext in the session.
             //
             JavaControlUtils.initializeControlContext( httpRequest, httpResponse, _servletContext );
-            
+
+            //
+            // Register the default URLRewriter
+            //
+            URLRewriterService.registerURLRewriter( request, new DefaultURLRewriter() );
+
             try
             {
                 ModuleConfig prevModuleConfig = RequestUtils.getRequestModuleConfig( httpRequest );
@@ -172,7 +186,7 @@
                 //
                 // Callback to the server adapter.
                 //
-                serverAdapter.endRequest( httpRequest, httpResponse );
+                _serverAdapter.endRequest( httpRequest, httpResponse );
             }
         }
         else

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java&r1=109308&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java	Tue Nov 30 23:09:49 2004
@@ -55,20 +55,20 @@
 import org.apache.beehive.netui.util.logging.Logger;
 import org.apache.beehive.netui.util.ServletUtils;
 import org.apache.beehive.netui.util.FileUtils;
-import org.apache.beehive.netui.pageflow.internal.JavaControlUtils;
-import org.apache.beehive.netui.pageflow.util.PageflowTagUtils;
-
-import org.apache.beehive.netui.pageflow.util.URLRewriterService;
+import org.apache.beehive.netui.core.urls.URLRewriterService;
 import org.apache.beehive.netui.pageflow.config.PageFlowActionForward;
 import org.apache.beehive.netui.pageflow.config.PageFlowActionMapping;
 import org.apache.beehive.netui.pageflow.config.PageFlowActionFormBean;
 import org.apache.beehive.netui.pageflow.interceptor.ActionInterceptorChain;
 import org.apache.beehive.netui.pageflow.interceptor.InterceptorForward;
 import org.apache.beehive.netui.pageflow.internal.ContextCache;
+import org.apache.beehive.netui.pageflow.internal.DefaultURLRewriter;
 import org.apache.beehive.netui.pageflow.internal.RequestValues;
 import org.apache.beehive.netui.pageflow.internal.InternalUtils;
+import org.apache.beehive.netui.pageflow.internal.JavaControlUtils;
 import org.apache.beehive.netui.pageflow.internal.FlowControllerAction;
 import org.apache.beehive.netui.pageflow.internal.DeferredPageFlowException;
+import org.apache.beehive.netui.pageflow.internal.ServerAdapterManager;
 import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
 import org.apache.beehive.netui.pageflow.scoping.ScopedRequest;
 import org.apache.beehive.netui.pageflow.handler.ForwardRedirectHandler;
@@ -106,6 +106,7 @@
     
     private Map< String, Class > _formBeanClasses = new HashMap< String, Class >();
     private Map< String, List< ActionMapping > > _overloadedActions = new HashMap< String, List< ActionMapping > >();
+    private ServerAdapter _serverAdapter;
     
 
     protected Action processActionCreate( HttpServletRequest request, HttpServletResponse response,
@@ -474,7 +475,6 @@
     {
         String uri = InternalUtils.getDecodedServletPath( request );
         ServletContext servletContext = getServletContext();
-        ServerAdapter serverAdapter = ContextCache.get( servletContext ).getServerAdapter();
 
         //
         // Allow weblogic to do a security check on forwarded requests, if that feature is enabled.
@@ -486,7 +486,7 @@
             // security check may not have been done for the request URI.  In this case, a redirect
             // to https may happen during checkSecurity().
             //
-            if ( serverAdapter.doSecurityRedirect( uri, request, response ) )
+            if ( _serverAdapter.doSecurityRedirect( uri, request, response ) )
             {
                 if ( _log.isDebugEnabled() )
                 {
@@ -567,8 +567,8 @@
                 {
                     String actionPath = paramName.substring( ACTION_OVERRIDE_PARAM_PREFIX_LEN );
 
-                    String qualifiedAction = PageflowTagUtils.qualifiedAction(servletContext,actionPath);
-                    actionPath = PageflowTagUtils.createActionPath(request, qualifiedAction );
+                    String qualifiedAction = InternalUtils.qualifiedAction(servletContext,actionPath);
+                    actionPath = InternalUtils.createActionPath(request, qualifiedAction );
 
                     if ( _log.isDebugEnabled() )
                     {
@@ -696,15 +696,26 @@
         contextCache.getReloadableClassHandler().reinit( request );
         
         //
+        // Initialize the ServletContext in the request.  Often, we need access to the ServletContext when we only
+        // have a ServletRequest.
+        //
+        InternalUtils.setServletContext( request, servletContext );
+        
+        //
         // Callback to the server adapter.
         //
-        contextCache.getServerAdapter().beginRequest( request, response );
+        _serverAdapter.beginRequest( request, response );
         
         //
         // Initialize the ControlBeanContext in the session.
         //
         JavaControlUtils.initializeControlContext( request, response, servletContext );
-        
+
+        //
+        // Register the default URLRewriter
+        //
+        URLRewriterService.registerURLRewriter( request, new DefaultURLRewriter() );
+
         try
         {
             processInternal( request, response );
@@ -719,7 +730,7 @@
             //
             // Callback to the server adapter.
             //
-            contextCache.getServerAdapter().endRequest( request, response );
+            _serverAdapter.endRequest( request, response );
         }
 
         if ( _log.isTraceEnabled() )
@@ -896,10 +907,10 @@
         }
     }
    
-    public void init( ActionServlet s, ModuleConfig mc )
+    public void init( ActionServlet actionServlet, ModuleConfig mc )
         throws ServletException
     {
-        super.init( s, mc );
+        super.init( actionServlet, mc );
         
         //
         // Cache a list of overloaded actions for each overloaded action path (actions are overloaded by form bean type).
@@ -910,6 +921,11 @@
         // Cache the form bean Classes by form bean name.
         //
         cacheFormClasses();
+        
+        //
+        // Cache a reference to the ServerAdapter.
+        //
+        _serverAdapter = ServerAdapterManager.getServerAdapter( getServletContext() );
     }
     
     private void cacheOverloadedActionMappings()
@@ -1243,7 +1259,7 @@
         String scopeID = request.getParameter( ScopedServletUtils.SCOPE_ID_PARAM );
         if ( scopeID != null )
         {
-            return PageflowTagUtils.addParam( url, ScopedServletUtils.SCOPE_ID_PARAM, scopeID );
+            return InternalUtils.addParam( url, ScopedServletUtils.SCOPE_ID_PARAM, scopeID );
         }
         else
         {
@@ -1421,22 +1437,20 @@
             {
                 try
                 {
-                    ServerAdapter sa = contextCache.getServerAdapter();
-                    
                     if ( request.isSecure() )
                     {
                         if ( sp.equals( SecurityProtocol.UNSECURE ) )
                         {
-                            securityRedirected =
-                                changeScheme( uri, SCHEME_UNSECURE, sa.getListenPort( request ), request, response );
+                            int listenPort = _serverAdapter.getListenPort( request );
+                            securityRedirected = changeScheme( uri, SCHEME_UNSECURE, listenPort, request, response );
                         }
                     }
                     else
                     {
                         if ( sp.equals( SecurityProtocol.SECURE ) )
                         {
-                            securityRedirected = changeScheme( uri, SCHEME_SECURE,  sa.getSecureListenPort( request ),
-                                                               request, response );
+                            int secureListenPort = _serverAdapter.getSecureListenPort( request );
+                            securityRedirected = changeScheme( uri, SCHEME_SECURE, secureListenPort, request, response );
                         }
                     }
                 }
@@ -1460,8 +1474,7 @@
      */
     protected void processNoCache( HttpServletRequest request, HttpServletResponse response )
     {
-        if ( moduleConfig.getControllerConfig().getNocache()
-                || ! ContextCache.get( getServletContext() ).getServerAdapter().isInProductionMode() )
+        if ( moduleConfig.getControllerConfig().getNocache() || ! _serverAdapter.isInProductionMode() )
         {
             //
             // The call to PageFlowJspFilter.preventCache() will cause caching to be prevented

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowStack.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowStack.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowStack.java&r1=109308&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowStack.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowStack.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowStack.java	Tue Nov 30 23:09:49 2004
@@ -22,9 +22,8 @@
 import org.apache.beehive.netui.pageflow.interceptor.InterceptorForward;
 import org.apache.beehive.netui.pageflow.interceptor.ActionInterceptorChain;
 import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
-import org.apache.beehive.netui.pageflow.internal.InternalUtils;
 import org.apache.beehive.netui.pageflow.internal.InternalConstants;
-import org.apache.beehive.netui.pageflow.internal.ContextCache;
+import org.apache.beehive.netui.pageflow.internal.ServerAdapterManager;
 
 import javax.servlet.http.HttpSessionBindingListener;
 import javax.servlet.http.HttpSessionBindingEvent;
@@ -207,7 +206,7 @@
     {
         String name =
             ScopedServletUtils.getScopedSessionAttrName( JPF_STACK_ATTR, PageFlowUtils.unwrapMultipart( request ) );
-        ContextCache.get( servletContext ).getServerAdapter().ensureFailover( name, this, request );
+        ServerAdapterManager.getServerAdapter( servletContext ).ensureFailover( name, this, request );
     }
     
     void save( HttpServletRequest request )

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=109309&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java&r1=109308&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java&r2=109309
==============================================================================
--- 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	Tue Nov 30 23:09:49 2004
@@ -21,8 +21,8 @@
 import org.apache.beehive.netui.pageflow.internal.ActionResultImpl;
 import org.apache.beehive.netui.pageflow.internal.InternalUtils;
 import org.apache.beehive.netui.pageflow.internal.RequestValues;
-import org.apache.beehive.netui.pageflow.internal.ContextCache;
 import org.apache.beehive.netui.pageflow.internal.InternalConstants;
+import org.apache.beehive.netui.pageflow.internal.ServerAdapterManager;
 import org.apache.beehive.netui.pageflow.scoping.ScopedRequest;
 import org.apache.beehive.netui.pageflow.scoping.ScopedResponse;
 import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
@@ -680,7 +680,7 @@
     public static SecurityProtocol getSecurityProtocol( String uri, ServletContext servletContext,
                                                         HttpServletRequest request )
     {
-        return ContextCache.get( servletContext ).getServerAdapter().getSecurityProtocol( uri, request );
+        return ServerAdapterManager.getServerAdapter( servletContext ).getSecurityProtocol( uri, request );
     }
     
     /**

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/SharedFlowController.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/SharedFlowController.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/SharedFlowController.java&r1=109308&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/SharedFlowController.java&r2=109309
==============================================================================
--- 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	Tue Nov 30 23:09:49 2004
@@ -26,8 +26,7 @@
 import javax.servlet.http.HttpSession;
 import javax.servlet.ServletContext;
 
-import org.apache.beehive.netui.pageflow.internal.InternalUtils;
-import org.apache.beehive.netui.pageflow.internal.ContextCache;
+import org.apache.beehive.netui.pageflow.internal.ServerAdapterManager;
 import static org.apache.beehive.netui.pageflow.internal.InternalConstants.*;
 
 
@@ -71,7 +70,7 @@
      */
     public void ensureFailover( HttpServletRequest request )
     {
-        ServerAdapter serverAdapter = ContextCache.get( getServletContext() ).getServerAdapter();
+        ServerAdapter serverAdapter = ServerAdapterManager.getServerAdapter( getServletContext() );
         serverAdapter.ensureFailover( SHARED_FLOW_ATTR_PREFIX + getClass().getName(), this, request );
     }
     

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ContextCache.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ContextCache.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ContextCache.java&r1=109308&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ContextCache.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ContextCache.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ContextCache.java	Tue Nov 30 23:09:49 2004
@@ -22,11 +22,8 @@
 import org.apache.beehive.netui.util.config.bean.NetuiConfigDocument;
 import org.apache.beehive.netui.util.config.bean.PageflowHandlers;
 import org.apache.beehive.netui.util.config.bean.PageflowConfig;
-import org.apache.beehive.netui.util.DiscoveryUtils;
 import org.apache.beehive.netui.pageflow.PageFlowActionServlet;
 import org.apache.beehive.netui.pageflow.PageFlowContextListener;
-import org.apache.beehive.netui.pageflow.ServerAdapter;
-import org.apache.beehive.netui.pageflow.DefaultServerAdapter;
 import org.apache.beehive.netui.pageflow.handler.LoginHandler;
 import org.apache.beehive.netui.pageflow.handler.ForwardRedirectHandler;
 import org.apache.beehive.netui.pageflow.handler.ReloadableClassHandler;
@@ -48,7 +45,6 @@
     private static final String DEFAULT_FWD_REDIRECT_HANDLER_CLASS = DefaultForwardRedirectHandler.class.getName();
     private static final String DEFAULT_RELOADABLE_CLASS_HANDLER_CLASS = DefaultReloadableClassHandler.class.getName();
     private static final String DEFAULT_EXCEPTIONS_HANDLER_CLASS = DefaultExceptionsHandler.class.getName();
-    private static final String SERVER_ADAPTER_PROP = "pageflow.serveradapter";
     private static final int DEFAULT_MAX_FORWARDS_PER_REQUEST = 25;
     private static final int DEFAULT_MAX_NESTING_STACK_DEPTH = 10;
     
@@ -62,8 +58,7 @@
     private LoginHandler _loginHandler = null;
     private ReloadableClassHandler _reloadableClassHandler = null;
     private ExceptionsHandler _exceptionsHandler = null;
-    private ServerAdapter _serverAdapter = null;
-    
+
     
     public ForwardRedirectHandler getForwardRedirectHandler()
     {
@@ -175,8 +170,6 @@
     }
     private ContextCache( ServletContext servletContext )
     {
-        _serverAdapter = createServerAdapter( servletContext );
-        
         //
         // Try loading some settings (max-forwards-per-requst, max-nesting-stack-depth, ensure-secure-forwards) from
         // the deprecated locations first, then fall back to netui-config.xml.
@@ -302,84 +295,5 @@
         }
         
         return null;
-    }
-    
-    private static ServerAdapter tryServerAdapter( Class serverAdapterClass, ServletContext servletContext )
-    {
-        try
-        {
-            ServerAdapter sa = ( ServerAdapter ) serverAdapterClass.newInstance();
-            
-            try
-            {
-                if ( sa.accept( servletContext ) )
-                {
-                    _log.info( "ServerAdapter " + serverAdapterClass.getName() + " accepted." );
-                    sa.setServletContext( servletContext );
-                    return sa;
-                }
-                else
-                {
-                    _log.info( "ServerAdapter " + serverAdapterClass.getName() + " is present but did not accept." );
-                }
-            }
-            catch ( Exception e )
-            {
-                _log.error( serverAdapterClass.getName() + ".accept() threw an exception.", e );
-            }
-            catch ( LinkageError e )
-            {
-                _log.error( serverAdapterClass.getName() + ".accept() caused a linkage error and may be out of date.", e );
-            }
-        }
-        catch ( InstantiationException e )
-        {
-            _log.error( "Could not create instance of ServerAdapter class " + serverAdapterClass.getName(), e );
-        }
-        catch ( IllegalAccessException e )
-        {
-            _log.error( "Could not create instance of ServerAdapter class " + serverAdapterClass.getName(), e );
-        }
-        catch ( Exception e )
-        {
-            _log.error( "Error creating instance of ServerAdapter class " + serverAdapterClass.getName(), e );
-        }
-        
-        return null;
-    }
-    
-    private static ServerAdapter createServerAdapter( ServletContext servletContext )
-    {
-        String serverAdapterClassName = System.getProperty( SERVER_ADAPTER_PROP );
-        
-        if ( serverAdapterClassName != null )
-        {
-            Class serverAdapterClass = DiscoveryUtils.loadServiceClass( serverAdapterClassName, ServerAdapter.class );
-            
-            if ( serverAdapterClass != null )
-            {
-                ServerAdapter sa = tryServerAdapter( serverAdapterClass, servletContext );
-                if ( sa != null ) return sa;
-            }
-        }
-        
-        Class[] classes = DiscoveryUtils.getServiceClasses( ServerAdapter.class );
-        
-        for ( int i = 0; i < classes.length; i++ )
-        {
-            ServerAdapter sa = tryServerAdapter( classes[i], servletContext );
-            if ( sa != null ) return sa;
-        }
-        
-        _log.info( "No ServerAdapter specified or discovered; using " + DefaultServerAdapter.class );
-        ServerAdapter sa =
-               new DefaultServerAdapter(){ public boolean accept( ServletContext servletContext ) { return true; } };
-        sa.setServletContext( servletContext );
-        return sa;
-    }
-
-    public ServerAdapter getServerAdapter()
-    {
-        return _serverAdapter;
     }
 }

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultLoginHandler.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultLoginHandler.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultLoginHandler.java&r1=109308&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultLoginHandler.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultLoginHandler.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultLoginHandler.java	Tue Nov 30 23:09:49 2004
@@ -41,12 +41,12 @@
     public void login( String username, String password, HttpServletRequest request, HttpServletResponse response )
         throws LoginException
     {
-        ContextCache.get( getServletContext() ).getServerAdapter().login( username, password, request, response );
+        ServerAdapterManager.getServerAdapter( getServletContext() ).login( username, password, request, response );
     }
 
     public void logout( boolean invalidateSessions, HttpServletRequest request, HttpServletResponse response )
     {
-        ContextCache.get( getServletContext() ).getServerAdapter().logout( invalidateSessions, request, response );
+        ServerAdapterManager.getServerAdapter( getServletContext() ).logout( invalidateSessions, request, response );
     }
 
     public boolean isUserInRole( String roleName, HttpServletRequest request )

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultReloadableClassHandler.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultReloadableClassHandler.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultReloadableClassHandler.java&r1=109308&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultReloadableClassHandler.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultReloadableClassHandler.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultReloadableClassHandler.java	Tue Nov 30 23:09:49 2004
@@ -52,7 +52,7 @@
         if ( false )
         {
             ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
-            ServerAdapter serverAdapter = ContextCache.get( servletContext ).getServerAdapter();
+            ServerAdapter serverAdapter = ServerAdapterManager.getServerAdapter( servletContext );
             File[] classDirs = null;
             
             // TODO: make this configurable in netui-config.xml.  You should be able to specify absolute files

Added: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultURLRewriter.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultURLRewriter.java?view=auto&rev=109309
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultURLRewriter.java	Tue Nov 30 23:09:49 2004
@@ -0,0 +1,210 @@
+/*
+ * 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 java.util.List;
+import java.net.URISyntaxException;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.beehive.netui.core.urls.MutableURI;
+import org.apache.beehive.netui.core.urls.URLRewriter;
+import org.apache.beehive.netui.pageflow.ServerAdapter;
+import org.apache.beehive.netui.pageflow.util.TemplateHelper;
+import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
+import org.apache.beehive.netui.util.logging.Logger;
+
+
+public class DefaultURLRewriter extends URLRewriter
+{
+    private static final Logger _log = Logger.getInstance( DefaultURLRewriter.class );
+
+    public String rewriteName( ServletContext servletContext, ServletRequest request, String name )
+    {
+        return name;
+    }
+
+    public void rewriteURL( ServletContext servletContext, ServletRequest request,
+                            ServletResponse response, MutableURI url, Type type, boolean needsToBeSecure )
+    {
+        // TODO... fix/modify TemplateHelper to use MutableURI or figure out a way for it subclass
+        // MutableURI. This is just the old code from the depricate DefaultURLRewriter.
+
+        // Look for the template config.  If it is found,
+        // do the lookup to get the right template.
+        // Apply the value to the template.
+        String templateType = org.apache.beehive.netui.pageflow.util.URLRewriter.ACTION_UNSECURE;
+        if ( type.equals( URLRewriter.Type.ACTION ) )
+        {
+            if ( needsToBeSecure )
+            {
+                templateType = org.apache.beehive.netui.pageflow.util.URLRewriter.ACTION_SECURE;
+            }
+            else
+            {
+                templateType = org.apache.beehive.netui.pageflow.util.URLRewriter.ACTION_UNSECURE;
+            }
+        }
+        else if ( type.equals( URLRewriter.Type.RESOURCE ) )
+        {
+            if ( needsToBeSecure )
+            {
+                templateType = org.apache.beehive.netui.pageflow.util.URLRewriter.RESOURCE_SECURE;
+            }
+            else
+            {
+                templateType = org.apache.beehive.netui.pageflow.util.URLRewriter.RESOURCE_UNSECURE;
+            }
+        }
+        TemplateHelper templateHelper = new TemplateHelper( ( HttpServletRequest ) request, ( HttpServletResponse ) response );
+        if ( templateHelper.hasTemplateRef( templateType ) )
+        {
+            // TODO.. this is a hack having to go back and forth between MutableURI and String.
+            String templateName = templateHelper.getTemplateName( templateType );
+            templateHelper.setTemplate( templateName );
+            templateHelper.setUrl( url.toString() );
+            String templateURI = templateHelper.toString();
+            try
+            {
+                MutableURI uri = new MutableURI( templateURI );
+                url.setScheme( uri.getScheme() );
+                url.setUserInfo( uri.getUserInfo() );
+                url.setHost( uri.getHost() );
+                url.setPort( uri.getPort() );
+                url.setPath( uri.getPath() );
+                url.setQuery( null );
+                url.addParameters( uri.getParameters(), true, null );
+                url.setFragment( uri.getFragment() );
+            }
+            catch ( URISyntaxException e )
+            {
+                _log.error( "Invalid URI from template " + templateName + ": " + templateURI );
+            }
+        }
+        else
+        {
+
+        ServerAdapter serverAdapter = ServerAdapterManager.getServerAdapter( servletContext );
+
+        // If url is not absolute, then do default secure/unsecure rewriting
+        if ( !url.isAbsolute() )
+        {
+            if ( needsToBeSecure )
+            {
+                if ( !request.isSecure() )
+                {
+                    int securePort = serverAdapter.getSecureListenPort( (HttpServletRequest) request );
+
+                    if (securePort != -1)
+                    {
+                        internalRewriteUrl( url, "https", securePort, request.getServerName() );
+                    }
+                    else
+                    {
+                        if (_log.isWarnEnabled())
+                        {
+                            _log.warn("Could not rewrite URL " + url.toString() + " to be secure because a secure port was" +
+                                      " not provided by the ServerAdapter.");
+                        }
+                    }
+                }
+            }
+            else
+            {
+                if ( request.isSecure() )
+                {
+                    int listenPort = serverAdapter.getListenPort((HttpServletRequest) request);
+
+                    if (listenPort != -1 )
+                    {
+                        internalRewriteUrl( url, "http", listenPort, request.getServerName() );
+                    }
+                    else
+                    {
+                        if (_log.isWarnEnabled())
+                        {
+                            _log.warn("Could not rewrite URL " + url.toString() + " to be secure because a secure port was" +
+                                      " not provided by the ServerAdapter.");
+                        }
+                    }
+                }
+            }
+        }
+        } // end temporary "if" statement for TemplateHelper
+
+        //
+        // If the current request has a special parameter that makes it scoped,
+        // add the parameter to the URL.
+        //
+        String scopeID = request.getParameter( ScopedServletUtils.SCOPE_ID_PARAM );
+        if ( scopeID != null )
+        {
+            // check to see if the scope-id param is already there.
+            List< String > parameters = url.getParameters( ScopedServletUtils.SCOPE_ID_PARAM );
+            if ( parameters != null && !parameters.contains( scopeID ) )
+            {
+                url.addParameter( ScopedServletUtils.SCOPE_ID_PARAM, scopeID, true, null );
+            }
+        }
+    }
+
+    private static void internalRewriteUrl( MutableURI url, String protocol, int port, String serverName )
+    {
+        // Need to build up the url
+        url.setScheme( protocol );
+        url.setHost( serverName );
+        url.setPort( port );
+    }
+
+    /**
+     * Determines if the passed-in Object is equivalent to this DefaultURLRewriter.
+     * Since there is no member data for this class they will all be equal.
+     *
+     * @param object the Object to test for equality.
+     * @return true if object is another instance of DefaultURLRewriter.
+     */
+    @Override
+    public boolean equals( Object object )
+    {
+        if ( object == this ) { return true; }
+
+        if ( object == null || !object.getClass().equals( this.getClass() ) )
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * Returns a hash code value for the object.
+     * Implemented in conjunction with equals() override.
+     * Since there is no member data for this class we
+     * always return the same value.
+     *
+     * @return a hash code value for this object.
+     */
+    @Override
+    public int hashCode()
+    {
+        return 0;
+    }
+}

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java&r1=109308&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java	Tue Nov 30 23:09:49 2004
@@ -17,10 +17,10 @@
  */
 package org.apache.beehive.netui.pageflow.internal;
 
+import org.apache.beehive.netui.core.urls.URLRewriterService;
 import org.apache.beehive.netui.pageflow.*;
 import org.apache.beehive.netui.pageflow.handler.ReloadableClassHandler;
 import org.apache.beehive.netui.pageflow.config.PageFlowControllerConfig;
-import org.apache.beehive.netui.pageflow.config.PageFlowActionMapping;
 import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
 import org.apache.beehive.netui.util.logging.Logger;
 import org.apache.beehive.netui.util.Bundle;
@@ -37,7 +37,6 @@
 import java.io.IOException;
 import java.io.PrintStream;
 import java.lang.reflect.Method;
-import java.lang.reflect.Field;
 import java.util.Map;
 import java.util.Iterator;
 import java.util.HashMap;
@@ -52,7 +51,6 @@
 import org.apache.struts.action.ActionServlet;
 import org.apache.struts.action.DynaActionFormClass;
 import org.apache.struts.action.DynaActionForm;
-import org.apache.struts.action.Action;
 import org.apache.struts.config.ModuleConfig;
 import org.apache.struts.config.ControllerConfig;
 import org.apache.struts.config.FormBeanConfig;
@@ -74,6 +72,7 @@
     private static final String ACTIONOUTPUT_MAP_ATTR = ATTR_PREFIX + "actionOutputs";
     private static final String BINDING_UPDATE_ERRORS_ATTR = ATTR_PREFIX + "bindingUpdateErrors";
     private static final String SHARED_FLOW_CLASSNAME_ATTR = ATTR_PREFIX + "sharedFlowClass";
+    private static final String SERVLET_CONTEXT_ATTR = ATTR_PREFIX + "servletContext";
     
     
     /**
@@ -95,7 +94,7 @@
                                          HttpServletResponse response, ServletContext servletContext )
             throws IOException
     {
-        boolean prodMode = ContextCache.get( servletContext ).getServerAdapter().isInProductionMode();
+        boolean prodMode = ServerAdapterManager.getServerAdapter( servletContext ).isInProductionMode();
         
         if ( prodMode && ! RequestValues.avoidDirectResponseOutput( request ) )
         {
@@ -976,11 +975,109 @@
         return pfConfig != null ? pfConfig.getMultipartHandler() : null;
     }
     
-    public static ServletContext getServletContext( HttpServletRequest request )
+    public static void setServletContext( HttpServletRequest request, ServletContext servletContext )
     {
-        assert request.getSession( false ) != null : "getServletContext() called before session created";
-        return request.getSession( true ).getServletContext();
+        ScopedServletUtils.getOuterRequest( request ).setAttribute( SERVLET_CONTEXT_ATTR, servletContext );
     }
     
+    public static ServletContext getServletContext( HttpServletRequest request )
+    {
+        HttpSession session = request.getSession( false );
+        return session != null
+               ? session.getServletContext()
+               : ( ServletContext ) ScopedServletUtils.getOuterRequest( request ).getAttribute( SERVLET_CONTEXT_ATTR ); 
+    }
 
+    public static String createActionURL( HttpServletRequest servletRequest, String qualifiedAction )
+    {
+        String pageURI = getDecodedURI( servletRequest );
+        int lastSlash = pageURI.lastIndexOf( '/' );
+        if ( lastSlash != -1 )
+        {
+            StringBuilder value = new StringBuilder( qualifiedAction.length() + 16 );
+            value.append( pageURI.substring( 0, lastSlash ) );
+            value.append( qualifiedAction );
+            return value.toString();
+        }
+
+        return qualifiedAction;
+    }
+
+    public static String createActionPath( HttpServletRequest request, String qualifiedAction )
+    {
+        ModuleConfig appConfig = ( ModuleConfig ) request.getAttribute( Globals.MODULE_KEY );
+        if ( appConfig != null )
+        {
+            StringBuilder value = new StringBuilder( qualifiedAction.length() + 16 );
+            value.append( appConfig.getPrefix() );
+            value.append( qualifiedAction );
+            return value.toString();
+        }
+
+        return qualifiedAction;
+    }
+
+    public static String qualifiedAction( ServletContext servletContext, String action )
+    {
+        assert action != null;
+        StringBuilder sb = new StringBuilder( 32 );
+
+        // Use our servlet mapping, if one is specified
+        String servletMapping = ( String ) servletContext.getAttribute( Globals.SERVLET_KEY );
+        if ( servletMapping != null )
+        {
+            String queryString = null;
+            int question = action.indexOf( '?' );
+            if ( question >= 0 )
+            {
+                queryString = action.substring( question );
+            }
+            String actionMapping = URLRewriterService.getActionMappingName( action );
+            if ( servletMapping.startsWith( "*." ) )
+            {
+                sb.append( actionMapping );
+                sb.append( servletMapping.substring( 1 ) );
+            }
+            else if ( servletMapping.endsWith( "/*" ) )
+            {
+                sb.append( servletMapping.substring( 0, servletMapping.length() - 2 ) );
+                sb.append( actionMapping );
+            }
+            else if ( servletMapping.equals( "/" ) )
+            {
+                sb.append( actionMapping );
+            }
+            if ( queryString != null )
+            {
+                sb.append( queryString );
+            }
+        }
+
+        // Otherwise, assume extension mapping is in use and extension is
+        // already included in the action property
+        else
+        {
+            if ( !action.startsWith( "/" ) )
+            {
+                sb.append( '/' );
+            }
+            sb.append( action );
+        }
+
+        return sb.toString();
+    }
+
+    /**
+     * Add a parameter to the given URL. Assumes there is no trailing
+     * anchor/fragment indicated with a '#'.
+     *
+     * @param url       the URL to which to append.
+     * @param paramName the name of the parameter to add.
+     * @param paramVal  the value of the parameter to add.
+     * @return the URL, with the given parameter added.
+     */
+    public static String addParam( String url, String paramName, String paramVal )
+    {
+        return url + ( url.indexOf( '?' ) != -1 ? '&' : '?' ) + paramName + '=' + paramVal;
+    }
 }

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/JavaControlUtils.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/JavaControlUtils.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/JavaControlUtils.java&r1=109308&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/JavaControlUtils.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/JavaControlUtils.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/JavaControlUtils.java	Tue Nov 30 23:09:49 2004
@@ -37,7 +37,6 @@
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.beehive.netui.util.logging.Logger;
-import org.apache.beehive.netui.pageflow.PageFlowUtils;
 
 
 /**
@@ -131,7 +130,7 @@
         if ( createIfMissing )
         {
             beanContext =
-                ContextCache.get( servletContext ).getServerAdapter().createControlBeanContext( request, response );
+                ServerAdapterManager.getServerAdapter( servletContext ).createControlBeanContext( request, response );
             request.getSession().setAttribute( CONTROL_CONTEXT_CLASSNAME, beanContext );
             request.setAttribute( CONTROL_CONTEXT_CLASSNAME, beanContext );
         }

Added: 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=auto&rev=109309
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ServerAdapterManager.java	Tue Nov 30 23:09:49 2004
@@ -0,0 +1,151 @@
+/*
+ * 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.DefaultServerAdapter;
+import org.apache.beehive.netui.pageflow.ServerAdapter;
+import org.apache.beehive.netui.util.logging.Logger;
+import org.apache.beehive.netui.util.DiscoveryUtils;
+
+import javax.servlet.ServletContext;
+
+
+/**
+ * @exclude
+ */
+public class ServerAdapterManager
+{
+    private static final Logger _log = Logger.getInstance( ServerAdapterManager.class );
+    
+    private static final String SERVER_ADAPTER_ATTR = "_netui:_serverAdapter";
+    private static final String SERVER_ADAPTER_PROP = "pageflow.serveradapter";
+
+    public static ServerAdapter getServerAdapter( ServletContext servletContext )
+    {
+        ServerAdapter adapter = ( ServerAdapter ) servletContext.getAttribute( SERVER_ADAPTER_ATTR );
+        
+        if ( adapter == null )
+        {
+            if ( _log.isErrorEnabled() )
+            {
+                _log.error( "ServletAdapter manager not initialized correctly." );
+            }
+            
+            //
+            // We can initialize it now, but it's not good because many requests could conceivably be in this
+            // code at the same time.
+            //
+            return init( servletContext );
+        }
+        
+        return adapter;
+    }
+    
+    public static ServerAdapter init( ServletContext servletContext )
+    {
+        ServerAdapter serverAdapter = createServerAdapter( servletContext );
+        servletContext.setAttribute( SERVER_ADAPTER_ATTR, serverAdapter );
+        return serverAdapter;
+    }
+
+    private static ServerAdapter tryServerAdapter( Class serverAdapterClass, ServletContext servletContext )
+    {
+        try
+        {
+            ServerAdapter sa = ( ServerAdapter ) serverAdapterClass.newInstance();
+
+            try
+            {
+                if ( sa.accept( servletContext ) )
+                {
+                    _log.info( "ServerAdapter " + serverAdapterClass.getName() + " accepted." );
+                    sa.setServletContext( servletContext );
+                    return sa;
+                }
+                else
+                {
+                    _log.info( "ServerAdapter " + serverAdapterClass.getName() + " is present but did not accept." );
+                }
+            }
+            catch ( Exception e )
+            {
+                _log.error( serverAdapterClass.getName() + ".accept() threw an exception.", e );
+            }
+            catch ( LinkageError e )
+            {
+                _log.error( serverAdapterClass.getName() + ".accept() caused a linkage error and may be out of date.", e );
+            }
+        }
+        catch ( InstantiationException e )
+        {
+            _log.error( "Could not create instance of ServerAdapter class " + serverAdapterClass.getName(), e );
+        }
+        catch ( IllegalAccessException e )
+        {
+            _log.error( "Could not create instance of ServerAdapter class " + serverAdapterClass.getName(), e );
+        }
+        catch ( Exception e )
+        {
+            _log.error( "Error creating instance of ServerAdapter class " + serverAdapterClass.getName(), e );
+        }
+
+        return null;
+    }
+
+    private static ServerAdapter createServerAdapter( ServletContext servletContext )
+    {
+        String serverAdapterClassName = System.getProperty( SERVER_ADAPTER_PROP );
+
+        if ( serverAdapterClassName != null )
+        {
+            Class serverAdapterClass = DiscoveryUtils.loadServiceClass( serverAdapterClassName, ServerAdapter.class );
+
+            if ( serverAdapterClass != null )
+            {
+                ServerAdapter sa = tryServerAdapter( serverAdapterClass, servletContext );
+                if ( sa != null )
+                {
+                    return sa;
+                }
+            }
+        }
+
+        Class[] classes = DiscoveryUtils.getServiceClasses( ServerAdapter.class );
+
+        for ( int i = 0; i < classes.length; i++ )
+        {
+            ServerAdapter sa = tryServerAdapter( classes[i], servletContext );
+            if ( sa != null )
+            {
+                return sa;
+            }
+        }
+
+        _log.info( "No ServerAdapter specified or discovered; using " + DefaultServerAdapter.class );
+        ServerAdapter sa =
+                new DefaultServerAdapter()
+                {
+                    public boolean accept( ServletContext servletContext )
+                    {
+                        return true;
+                    }
+                };
+        sa.setServletContext( servletContext );
+        return sa;
+    }
+}

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/DefaultURLRewriter.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/DefaultURLRewriter.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/DefaultURLRewriter.java&r1=109308&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/DefaultURLRewriter.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/DefaultURLRewriter.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/DefaultURLRewriter.java	Tue Nov 30 23:09:49 2004
@@ -18,10 +18,9 @@
 package org.apache.beehive.netui.pageflow.util;
 
 //internal imports
-import org.apache.beehive.netui.pageflow.PageFlowUtils;
 import org.apache.beehive.netui.pageflow.ServerAdapter;
 import org.apache.beehive.netui.pageflow.internal.InternalUtils;
-import org.apache.beehive.netui.pageflow.internal.ContextCache;
+import org.apache.beehive.netui.pageflow.internal.ServerAdapterManager;
 import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
 import org.apache.beehive.netui.util.FileUtils;
 import org.apache.beehive.netui.util.logging.Logger;
@@ -33,6 +32,9 @@
 import javax.servlet.http.HttpServletResponse;
 
 
+/**
+ * @deprecated Use {@link org.apache.beehive.netui.pageflow.internal.DefaultURLRewriter} instead.
+ */
 public class DefaultURLRewriter extends URLRewriter
 {
     private static final Logger _log = Logger.getInstance( DefaultURLRewriter.class );
@@ -58,7 +60,7 @@
         }
         else
         {
-            ServerAdapter serverAdapter = ContextCache.get(servletContext).getServerAdapter();
+            ServerAdapter serverAdapter = ServerAdapterManager.getServerAdapter(servletContext);
             
             //Need to do default secure/unsecure rewriting
             if ((type.equals(URLRewriter.ACTION_SECURE) || (type.equals(URLRewriter.RESOURCE_SECURE))))
@@ -111,7 +113,7 @@
         {
             // TODO: after we've rewritten this to use mutable URLs (i.e., when it's easier to check for existing
             // parameters, we should check to see if the scope-id param is already there.
-            url = PageflowTagUtils.addParam(url, ScopedServletUtils.SCOPE_ID_PARAM, scopeID);
+            url = InternalUtils.addParam(url, ScopedServletUtils.SCOPE_ID_PARAM, scopeID);
         }
         
         // Continue chaining if there is another

Added: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/OldURLRewriterWrapper.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/OldURLRewriterWrapper.java?view=auto&rev=109309
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/OldURLRewriterWrapper.java	Tue Nov 30 23:09:49 2004
@@ -0,0 +1,148 @@
+/*
+ * 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.util;
+
+import org.apache.beehive.netui.core.urls.MutableURI;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+
+/**
+ * This is just a temporary class to wrap old URLRewriter classes and
+ * regsiter them with the new URLRewriterService.
+ * <p> Should be using {@link org.apache.beehive.netui.core.urls.URLRewriter}
+ * instead. </p>
+ */
+class OldURLRewriterWrapper extends org.apache.beehive.netui.core.urls.URLRewriter
+{
+    private org.apache.beehive.netui.pageflow.util.URLRewriter _oldURLRewriter;
+
+    /**
+     * Constructs a <code>OldURLRewriterWrapper</code> for an old, deprecated
+     * {@link org.apache.beehive.netui.pageflow.util.URLRewriter}.
+     *
+     * @param oldURLRewriter the deprecated rewriter to wrap.
+     */
+    public OldURLRewriterWrapper( org.apache.beehive.netui.pageflow.util.URLRewriter oldURLRewriter )
+    {
+        _oldURLRewriter = oldURLRewriter;
+    }
+
+    /**
+     * Returns the old, deprecated {@link org.apache.beehive.netui.pageflow.util.URLRewriter}
+     * wrapped inside this <code>OldURLRewriterWrapper</code> object.
+     *
+     * @return the deprecated rewriter to wrap.
+     */
+    public org.apache.beehive.netui.pageflow.util.URLRewriter getURLRewriter()
+    {
+        return _oldURLRewriter;
+    }
+
+    public String rewriteName( ServletContext servletContext, ServletRequest request, String name )
+    {
+        return _oldURLRewriter.rewriteName( servletContext, request, name );
+    }
+
+    public void rewriteURL( ServletContext servletContext, ServletRequest request,
+                            ServletResponse response, MutableURI uri,
+                            org.apache.beehive.netui.core.urls.URLRewriter.Type type,
+                            boolean needsToBeSecure )
+    {
+        String tempType = URLRewriter.RESOURCE_UNSECURE;
+
+        if ( type.equals( org.apache.beehive.netui.core.urls.URLRewriter.Type.ACTION ) )
+        {
+            if ( needsToBeSecure )
+            {
+                tempType = URLRewriter.ACTION_SECURE;
+            }
+            else
+            {
+                tempType = URLRewriter.ACTION_UNSECURE;
+            }
+        }
+        else if ( type.equals( org.apache.beehive.netui.core.urls.URLRewriter.Type.RESOURCE ) )
+        {
+            if ( needsToBeSecure )
+            {
+                tempType = URLRewriter.RESOURCE_SECURE;
+            }
+            else
+            {
+                tempType = URLRewriter.RESOURCE_UNSECURE;
+            }
+        }
+
+        String rewrittenURL = _oldURLRewriter.rewriteURL( servletContext, request, response,
+                                                          uri.toString(), tempType );
+        try
+        {
+            MutableURI newURI = new MutableURI( rewrittenURL );
+            uri.setScheme( newURI.getScheme() );
+            uri.setUserInfo( newURI.getUserInfo() );
+            uri.setHost( newURI.getHost() );
+            uri.setPort( newURI.getPort() );
+            uri.setPath( newURI.getPath() );
+            uri.setQuery( null );
+            uri.addParameters( newURI.getParameters(), true, null );
+            uri.setFragment( newURI.getFragment() );
+        }
+        catch ( java.net.URISyntaxException e )
+        {
+        }
+    }
+
+    /**
+     * Determines if the passed-in Object is equivalent to this DefaultURLRewriter.
+     * Since there is no member data for this class they will all be equal.
+     *
+     * @param object the Object to test for equality.
+     * @return true if object is another instance of DefaultURLRewriter.
+     */
+    @Override
+    public boolean equals( Object object )
+    {
+        if ( object == this ) { return true; }
+
+        if ( object == null || !object.getClass().equals( this.getClass() ) )
+        {
+            return false;
+        }
+
+        org.apache.beehive.netui.pageflow.util.URLRewriter rewriter =
+                (( OldURLRewriterWrapper ) object ).getURLRewriter();
+        return _oldURLRewriter.equals( rewriter );
+    }
+
+    /**
+     * Returns a hash code value for the object.
+     * Implemented in conjunction with equals() override.
+     * Just returns the hash code value of the old rewriter
+     * this class wraps.
+     *
+     * @return a hash code value for this object.
+     */
+    @Override
+    public int hashCode()
+    {
+        return _oldURLRewriter.hashCode();
+    }
+}

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/PageflowTagUtils.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/PageflowTagUtils.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/PageflowTagUtils.java&r1=109308&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/PageflowTagUtils.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/PageflowTagUtils.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/PageflowTagUtils.java	Tue Nov 30 23:09:49 2004
@@ -48,7 +48,7 @@
 
 
 /**
- * @exclude
+ * @deprecated This class has been replaced with an internal utility ({@link org.apache.beehive.netui.tags.internal.PageFlowTagUtils}).  It will be removed in a future release.
  */ 
 public class PageflowTagUtils
 {

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/TemplateHelper.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/TemplateHelper.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/TemplateHelper.java&r1=109308&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/TemplateHelper.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/TemplateHelper.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/TemplateHelper.java	Tue Nov 30 23:09:49 2004
@@ -26,8 +26,8 @@
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.ServletContext;
 
-import org.apache.beehive.netui.pageflow.internal.ContextCache;
 import org.apache.beehive.netui.pageflow.internal.InternalUtils;
+import org.apache.beehive.netui.pageflow.internal.ServerAdapterManager;
 
 /**
  * Class for creating URLs from parameterized templates.
@@ -565,7 +565,7 @@
             else {
                 // Append the webapp name
                 ServletContext servletContext = InternalUtils.getServletContext(httpRequest);
-                String webAppName = ContextCache.get(servletContext).getServerAdapter().getFullContextPath(httpRequest);
+                String webAppName = ServerAdapterManager.getServerAdapter(servletContext).getFullContextPath(httpRequest);
                 buf = appendEnsureSeparator(buf, webAppName);
 
                 // Append the servlet name (mapping)
@@ -654,7 +654,7 @@
             else {
                 // Append the webapp name
                 ServletContext servletContext = InternalUtils.getServletContext(httpRequest);
-                String webAppName = ContextCache.get(servletContext).getServerAdapter().getFullContextPath(httpRequest);
+                String webAppName = ServerAdapterManager.getServerAdapter(servletContext).getFullContextPath(httpRequest);
                 buf.append(webAppName);
 
                 // Append the servlet name (mapping)

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriter.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriter.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriter.java&r1=109308&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriter.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriter.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriter.java	Tue Nov 30 23:09:49 2004
@@ -25,6 +25,8 @@
 /**
  * URL rewriter interface.  Offers methods for rewriting URLs/query parameters, and adding URL rewriters
  * to the chain.
+ *
+ * @deprecated Use {@link org.apache.beehive.netui.core.urls.URLRewriter} instead.
  */
 public abstract class URLRewriter
 {

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriterService.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriterService.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriterService.java&r1=109308&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriterService.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriterService.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriterService.java	Tue Nov 30 23:09:49 2004
@@ -17,16 +17,11 @@
  */
 package org.apache.beehive.netui.pageflow.util;
 
-
-
-//java imports
-
-//internal imports
+import org.apache.beehive.netui.core.urls.MutableURI;
 import org.apache.beehive.netui.pageflow.PageFlowUtils;
 import org.apache.beehive.netui.pageflow.SecurityProtocol;
+import org.apache.beehive.netui.util.logging.Logger;
 
-//external imports
-import javax.servlet.ServletRequest;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
@@ -36,11 +31,14 @@
 
 /**
  * Methods for registering URL rewriters, and for rewriting URLs using registered rewriters.
- */ 
+ *
+ * @deprecated Use {@link org.apache.beehive.netui.core.urls.URLRewriterService} instead.
+ */
 public class URLRewriterService
 {
     private static URLRewriter defaultRewriter = new DefaultURLRewriter();
     private static String URL_REWRITER_KEY = "url_rewriter";
+    private static final Logger _log = Logger.getInstance( URLRewriterService.class );
 
 
     /**
@@ -62,20 +60,7 @@
      */ 
     public static String rewriteName(ServletContext servletContext, ServletRequest request, String name)
     {
-        URLRewriter rewriter = (URLRewriter) request.getAttribute(URL_REWRITER_KEY);
-        String rewrittenName = null;
-
-        if (rewriter != null)
-        {
-            rewrittenName = rewriter.rewriteName(servletContext, request, name);
-        }
-        else
-        {
-            rewrittenName = defaultRewriter.rewriteName(servletContext, request, name);
-        }
-
-        return rewrittenName;
-
+        return org.apache.beehive.netui.core.urls.URLRewriterService.rewriteName( servletContext, request, name );
     }
 
     /**
@@ -103,7 +88,7 @@
 
     /**
      * Rewrite the given URL, using the registered URLRewriter.
-     * 
+     *
      * @param servletContext the current ServletContext.
      * @param request the current HttpServletRequest.
      * @param response the current HttpServletResponse.
@@ -118,21 +103,41 @@
      * @param doEncode if <code>true</code>, the rewritten URL will be encoded using
      *                 {@link HttpServletResponse#encodeRedirectURL}.
      * @return the rewritten URL.
-     * 
+     *
      * @see #registerURLRewriter
-     */ 
+     */
     public static String rewriteURL(ServletContext servletContext, ServletRequest request, ServletResponse response, String url, String type, boolean doEncode)
     {
-        URLRewriter rewriter = (URLRewriter) request.getAttribute(URL_REWRITER_KEY);
         String rewrittenURL = null;
-
-        if (rewriter != null)
-        {
-            rewrittenURL = rewriter.rewriteURL(servletContext, request, response, url, type);
+        MutableURI mutableUri = null;
+        try {
+            mutableUri = new MutableURI( url );
+            org.apache.beehive.netui.core.urls.URLRewriter.Type tempType =
+                    org.apache.beehive.netui.core.urls.URLRewriter.Type.RESOURCE;
+            boolean needsToBeSecure = false;
+
+            if ( type.equals( URLRewriter.ACTION_UNSECURE ) )
+            {
+                tempType = org.apache.beehive.netui.core.urls.URLRewriter.Type.ACTION;
+            }
+            else if ( type.equals( URLRewriter.ACTION_SECURE ) )
+            {
+                tempType = org.apache.beehive.netui.core.urls.URLRewriter.Type.ACTION;
+                needsToBeSecure = true;
+            }
+            else if ( type.equals( URLRewriter.RESOURCE_SECURE ) )
+            {
+                needsToBeSecure = true;
+            }
+
+            org.apache.beehive.netui.core.urls.URLRewriterService.rewriteURL( servletContext, request, response,
+                                                                              mutableUri, tempType, needsToBeSecure );
+            rewrittenURL = mutableUri.toString();
         }
-        else
+        catch ( java.net.URISyntaxException e )
         {
-            rewrittenURL = defaultRewriter.rewriteURL(servletContext, request, response, url, type);
+            _log.error( "Invalid URI: " + url );
+            rewrittenURL = url;
         }
 
         if (doEncode)
@@ -142,18 +147,19 @@
         }
 
         return rewrittenURL;
-
     }
 
     /**
      * Register a URLRewriter in the request.  This rewriter will be used if {@link #rewriteURL} is called.
-     * 
+     *
      * @param request the current HttpServletRequest.
      * @param rewriter the URLRewriter to register.
-     */ 
+     */
     public static void registerURLRewriter(ServletRequest request, URLRewriter rewriter)
     {
         request.setAttribute(URL_REWRITER_KEY, rewriter);
+        org.apache.beehive.netui.core.urls.URLRewriter rewriterWrapper = new OldURLRewriterWrapper(rewriter);
+        org.apache.beehive.netui.core.urls.URLRewriterService.registerURLRewriter(request, rewriterWrapper);
     }
 
     /**
@@ -167,6 +173,8 @@
     {
         URLRewriter rewriter = (URLRewriter) request.getAttribute(URL_REWRITER_KEY);
         request.removeAttribute(URL_REWRITER_KEY);
+        org.apache.beehive.netui.core.urls.URLRewriter rewriterWrapper = new OldURLRewriterWrapper(rewriter);
+        org.apache.beehive.netui.core.urls.URLRewriterService.unregisterURLRewriter(request, rewriterWrapper);
 
         return rewriter;
     }
@@ -188,27 +196,12 @@
      */
     public static String getActionMappingName(String action)
     {
-        String value = action;
-        int question = action.indexOf("?");
-        if (question >= 0) {
-            value = value.substring(0, question);
-        }
-        int slash = value.lastIndexOf("/");
-        int period = value.lastIndexOf(".");
-        if ((period >= 0) && (period > slash)) {
-            value = value.substring(0, period);
-        }
-
-        if (value.startsWith("/")) {
-            return (value);
-        } else {
-            return ("/" + value);
-        }
+        return org.apache.beehive.netui.core.urls.URLRewriterService.getActionMappingName( action );
     }
 
     /**
      * Tell whether a given URI should be written to be secure.
-     * 
+     *
      * @param request the current HttpServletRequest.
      * @param context the current ServletContext.
      * @param uri the URI to check.
@@ -230,22 +223,21 @@
      *                 is unsecure ({@link javax.servlet.http.HttpServletRequest#isSecure} returns
      *                 <code>false</code>).
      *         </ul>
-     */ 
+     */
     public static boolean needsSecure(ServletRequest request, ServletContext context, String uri,
                                       boolean stripContextPath)
     {
-
         //Get the web-app relative path for security check
         String secureCheck = uri;
         if (stripContextPath)
         {
             String contextPath = ((HttpServletRequest)request).getContextPath();
+            if (secureCheck.startsWith(contextPath))
+            {
+                secureCheck = secureCheck.substring(contextPath.length());
+            }
+        }
 
-             if (secureCheck.startsWith(contextPath))
-             {
-                 secureCheck = secureCheck.substring(contextPath.length());
-             }
-         }
         boolean secure = false;
         if (secureCheck.indexOf("?") > -1)
         {
@@ -258,10 +250,13 @@
             secure = request.isSecure();
         }
         else
+        {
             secure = sp.equals(SecurityProtocol.SECURE);
+        }
+
         return secure;
     }
-    
+
     /**
      * Tell whether rewritten form actions should be allowed to have query parameters.  If this returns
      * <code>false</code>, then a form-tag implementation should render query parameters into hidden
@@ -270,7 +265,6 @@
      */
     public static boolean allowParamsOnFormAction(ServletContext servletContext, ServletRequest request)
     {
-        URLRewriter rewriter = (URLRewriter) request.getAttribute(URL_REWRITER_KEY);
-        return (rewriter != null ? rewriter.allowParamsOnFormAction(servletContext, request) : true);
+        return org.apache.beehive.netui.core.urls.URLRewriterService.allowParamsOnFormAction( servletContext, request );
     }
 }

Modified: incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedRequest.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedRequest.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedRequest.java&r1=109308&p2=incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedRequest.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedRequest.java	(original)
+++ incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedRequest.java	Tue Nov 30 23:09:49 2004
@@ -81,6 +81,12 @@
     public boolean hasListenScopes();
     
     /**
+     * Same as <code>getAttribute</code>, but allows outer request attributes to be hidden explicitly, even if the implementation
+     * of getAttribute shows them by default.
+     */ 
+    public Object getAttribute( String attrName, boolean allowOuterRequestAttributes );
+    
+    /**
      * @exclude
      */ 
     public Map filterParameterMap( Map parameterMap );

Modified: incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedServletUtils.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedServletUtils.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedServletUtils.java&r1=109308&p2=incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedServletUtils.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedServletUtils.java	(original)
+++ incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedServletUtils.java	Tue Nov 30 23:09:49 2004
@@ -329,6 +329,23 @@
     }
     
     /**
+     * Get an attribute from the given request, and if it is a {@link ScopedRequest}, ensure that the attribute
+     * is <strong>not</strong> "showing through" from the outer request, even if the ScopedRequest allows that by
+     * default.
+     * 
+     * @exclude
+     */ 
+    public static Object getScopedRequestAttribute( String attrName, ServletRequest request )
+    {
+        if ( request instanceof ScopedRequest )
+        {
+            return ( ( ScopedRequest ) request ).getAttribute( attrName, false );
+        }
+        
+        return request.getAttribute( attrName );
+    }
+    
+    /**
      * Get the request URI, relative to the webapp root.
      *
      * @param request the current HttpServletRequest.

Modified: incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/internal/ScopedRequestImpl.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/internal/ScopedRequestImpl.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/internal/ScopedRequestImpl.java&r1=109308&p2=incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/internal/ScopedRequestImpl.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/internal/ScopedRequestImpl.java	(original)
+++ incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/internal/ScopedRequestImpl.java	Tue Nov 30 23:09:49 2004
@@ -60,7 +60,6 @@
     private String _overridePathInfo = null;
     private boolean _isActiveRequest = false;
     private boolean _seeOuterRequestAttributes = false;
-    private Set _hiddenOuterRequestAttrs;
     private Set _visibleOuterRequestAttrs;
     private Map _additionalParameters;
 
@@ -82,13 +81,6 @@
         setRequestURI( overrideRequestURI );
         _seeOuterRequestAttributes = seeOuterRequestAttributes;
         
-        if ( seeOuterRequestAttributes )
-        {
-            // TODO: this isn't initialized in the ServletContext yet -- the mechanism probably will change.
-            _hiddenOuterRequestAttrs = ( Set ) servletContext.getAttribute( HIDDEN_OUTER_REQUEST_ATTRS_ATTR );
-            if ( _hiddenOuterRequestAttrs == null ) _hiddenOuterRequestAttrs = new HashSet();
-        }
-        
         if ( ! seeOuterRequestAttributes ) _visibleOuterRequestAttrs = new HashSet();
     }
 
@@ -475,6 +467,13 @@
 
     public final Object getAttribute( String attrName )
     {
+        return getAttribute( attrName, true );
+    }
+    
+    public final Object getAttribute( String attrName, boolean allowOuterRequestAttributes )
+    {
+        if ( ! allowOuterRequestAttributes ) return _scopedContainer.getAttribute( attrName );
+        
         ServletRequest outerRequest = getRequest();
         
         if ( ! _seeOuterRequestAttributes && _visibleOuterRequestAttrs.contains( attrName ) )
@@ -484,7 +483,7 @@
 
         Object value = _scopedContainer.getAttribute( attrName );
         
-        if ( value == null && _seeOuterRequestAttributes && ! _hiddenOuterRequestAttrs.contains( attrName ) )
+        if ( value == null && _seeOuterRequestAttributes )
         {
             value = outerRequest.getAttribute( attrName );
         }
@@ -526,8 +525,7 @@
         {
             for ( Enumeration e = getRequest().getAttributeNames(); e.hasMoreElements(); )
             {
-                Object attrName = e.nextElement();
-                if ( ! _hiddenOuterRequestAttrs.contains( attrName ) ) set.add( attrName );
+                set.add( e.nextElement() );
             }
         }
 

Modified: incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/model/PagerModel.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/model/PagerModel.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/model/PagerModel.java&r1=109308&p2=incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/model/PagerModel.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/model/PagerModel.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/model/PagerModel.java	Tue Nov 30 23:09:49 2004
@@ -19,7 +19,7 @@
 
 import org.apache.beehive.netui.databinding.datagrid.services.PagerService;
 import org.apache.beehive.netui.databinding.datagrid.util.JspUtil;
-import org.apache.beehive.netui.pageflow.util.PageflowTagUtils;
+import org.apache.beehive.netui.pageflow.internal.InternalUtils;
 import org.apache.beehive.netui.util.logging.Logger;
 
 import javax.servlet.jsp.PageContext;
@@ -106,8 +106,8 @@
         String pageUri = null;
         if (_pageAction != null) {
             PageContext pageContext = JspUtil.getPageContext(_model.getJspContext());
-            String qualifiedAction = PageflowTagUtils.qualifiedAction(pageContext.getServletContext(), _pageAction);
-            pageUri = PageflowTagUtils.createActionURL((HttpServletRequest) pageContext.getRequest(), qualifiedAction);
+            String qualifiedAction = InternalUtils.qualifiedAction(pageContext.getServletContext(), _pageAction);
+            pageUri = InternalUtils.createActionURL((HttpServletRequest) pageContext.getRequest(), qualifiedAction);
         } else if (_pageHref != null) {
             pageUri = _pageHref;
         }

Modified: incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/rendering/impl/AbstractPagerRenderer.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/rendering/impl/AbstractPagerRenderer.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/rendering/impl/AbstractPagerRenderer.java&r1=109308&p2=incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/rendering/impl/AbstractPagerRenderer.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/rendering/impl/AbstractPagerRenderer.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/rendering/impl/AbstractPagerRenderer.java	Tue Nov 30 23:09:49 2004
@@ -22,10 +22,6 @@
 import org.apache.beehive.netui.databinding.datagrid.model.PagerModel;
 import org.apache.beehive.netui.databinding.datagrid.model.DataGridModel;
 import org.apache.beehive.netui.databinding.datagrid.rendering.IPagerRenderer;
-import org.apache.beehive.netui.databinding.datagrid.util.JspUtil;
-import org.apache.beehive.netui.pageflow.util.PageflowTagUtils;
-
-import javax.servlet.jsp.PageContext;
 
 /**
  * todo: lots of i18n here

Modified: incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/rendering/impl/FirstPreviousNextLastPagerRenderer.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/rendering/impl/FirstPreviousNextLastPagerRenderer.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/rendering/impl/FirstPreviousNextLastPagerRenderer.java&r1=109308&p2=incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/rendering/impl/FirstPreviousNextLastPagerRenderer.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/rendering/impl/FirstPreviousNextLastPagerRenderer.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/rendering/impl/FirstPreviousNextLastPagerRenderer.java	Tue Nov 30 23:09:49 2004
@@ -18,13 +18,9 @@
 package org.apache.beehive.netui.databinding.datagrid.rendering.impl;
 
 import org.apache.beehive.netui.util.logging.Logger;
-import org.apache.beehive.netui.pageflow.util.PageflowTagUtils;
 import org.apache.beehive.netui.databinding.datagrid.model.PagerModel;
 import org.apache.beehive.netui.databinding.datagrid.model.DataGridModel;
 import org.apache.beehive.netui.databinding.datagrid.services.PagerService;
-import org.apache.beehive.netui.databinding.datagrid.util.JspUtil;
-
-import javax.servlet.jsp.PageContext;
 
 public class FirstPreviousNextLastPagerRenderer
     extends AbstractPagerRenderer

Modified: incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/rendering/impl/PreviousNextPagerRenderer.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/rendering/impl/PreviousNextPagerRenderer.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/rendering/impl/PreviousNextPagerRenderer.java&r1=109308&p2=incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/rendering/impl/PreviousNextPagerRenderer.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/rendering/impl/PreviousNextPagerRenderer.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/rendering/impl/PreviousNextPagerRenderer.java	Tue Nov 30 23:09:49 2004
@@ -20,11 +20,7 @@
 import org.apache.beehive.netui.databinding.datagrid.model.PagerModel;
 import org.apache.beehive.netui.databinding.datagrid.model.DataGridModel;
 import org.apache.beehive.netui.databinding.datagrid.services.PagerService;
-import org.apache.beehive.netui.databinding.datagrid.util.JspUtil;
-import org.apache.beehive.netui.pageflow.util.PageflowTagUtils;
 import org.apache.beehive.netui.util.logging.Logger;
-
-import javax.servlet.jsp.PageContext;
 
 public class PreviousNextPagerRenderer
     extends AbstractPagerRenderer

Modified: incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/util/JspUtil.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/util/JspUtil.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/util/JspUtil.java&r1=109308&p2=incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/util/JspUtil.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/util/JspUtil.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/util/JspUtil.java	Tue Nov 30 23:09:49 2004
@@ -17,21 +17,17 @@
  */
 package org.apache.beehive.netui.databinding.datagrid.util;
 
+import java.net.URISyntaxException;
 import java.util.HashMap;
 import java.util.Map;
-import java.net.MalformedURLException;
 import javax.servlet.jsp.JspContext;
 import javax.servlet.jsp.PageContext;
 import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.ServletContext;
 
+import org.apache.beehive.netui.core.urls.MutableURI;
 import org.apache.beehive.netui.util.logging.Logger;
-import org.apache.beehive.netui.util.FileUtils;
-import org.apache.beehive.netui.pageflow.util.URLRewriter;
-import org.apache.beehive.netui.pageflow.util.PageflowTagUtils;
-import org.apache.beehive.netui.pageflow.util.URLRewriterService;
 import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
+import org.apache.beehive.netui.tags.PageFlowTagUtils;
 
 public class JspUtil
 {
@@ -54,49 +50,9 @@
     }
 
     public static final String createURL(String href, String action, String location, String scope, Map params, JspContext jspContext)
-        throws MalformedURLException
+        throws URISyntaxException
     {
         PageContext pageContext = getPageContext(jspContext);
-        HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
-        HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
-        ServletContext ctxt = pageContext.getServletContext();
-        boolean absoluteUrl = false;
-
-        // Generate the opening anchor element
-        String type = URLRewriter.ACTION_UNSECURE;
-
-        String internalHref = null;
-        if(action != null)
-        {
-            // simply set this to the result of mangling the action
-            String qualifiedAction = PageflowTagUtils.qualifiedAction(ctxt,action);
-            String actionUrl = PageflowTagUtils.createActionPath(request, qualifiedAction);
-            if(URLRewriterService.needsSecure(request, ctxt, actionUrl, false))
-                type = URLRewriter.ACTION_SECURE;
-            internalHref = PageflowTagUtils.createActionURL(request, qualifiedAction);
-        }
-        else if(href != null)
-        {
-            internalHref = href;
-            if(FileUtils.isAbsoluteURI(internalHref))
-            {
-                absoluteUrl = true;
-            }
-            else if(!internalHref.startsWith("/"))
-            {
-                // for internal hrefs, we need to see if we need to secure the request
-                if(!href.equals(""))
-                {
-                    String reqUri = request.getRequestURI();
-                    String path = reqUri.substring(0, reqUri.lastIndexOf("/") + 1);
-                    internalHref = path + internalHref;
-
-                    // is this a secure operation?
-                    if((!absoluteUrl) && (URLRewriterService.needsSecure(request, ctxt, internalHref, true)))
-                        type = URLRewriter.ACTION_SECURE;
-                }
-            }
-        }
 
         // Add the jpfScopeID parameter, if the scope attribute is present.
         if(scope != null)
@@ -108,35 +64,24 @@
             params.put(ScopedServletUtils.SCOPE_ID_PARAM, scope);
         }
 
-        if(!absoluteUrl)
+        // Generate the opening anchor element
+        MutableURI uri = null;
+        if(action != null)
         {
-            internalHref = calculateURL(pageContext, internalHref, location, params);
+            uri = PageFlowTagUtils.rewriteActionURL(pageContext, action, params, location);
         }
-        else
+        else if(href != null)
         {
-            if((params != null) && (params.size() > 0))
-            {
-                StringBuilder sb = new StringBuilder(internalHref);
-                String encoding = response.getCharacterEncoding();
-                PageflowTagUtils.addParameters(sb, encoding, false, params);
-                internalHref = sb.toString();
-            }
+            //TODO... OK to use rewrittenResourceURL implying type=RESOURCE for rewriting?
+            uri = PageFlowTagUtils.rewriteResourceURL(pageContext, href, params, location);
         }
 
-        assert internalHref != null;
+        assert uri != null;
 
-        if(!absoluteUrl)
-        {
-            internalHref = URLRewriterService.rewriteURL(ctxt, request, response, internalHref, type);
-            //internalHref = qualifyUrlToContext(internalHref);
+        //TODO... shouldn't this also be a call to response.encodeURL(uri.toString()) for session ID?
+        if (uri.isAbsolute()) {
+            return uri.toXMLString();
         }
-        return internalHref;
-    }
-
-    private static final String calculateURL(PageContext pageContext, String href, String location, Map params)
-        throws MalformedURLException
-    {
-        String url = PageflowTagUtils.computeURL(pageContext, null, href, null, null, params, location, true);
-        return url;
+        return uri.toString();
     }
 }

Modified: incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/AnchorColumn.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/AnchorColumn.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/AnchorColumn.java&r1=109308&p2=incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/AnchorColumn.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/AnchorColumn.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/AnchorColumn.java	Tue Nov 30 23:09:49 2004
@@ -32,7 +32,7 @@
 import org.apache.beehive.netui.util.logging.Logger;
 import org.apache.beehive.netui.util.ParamHelper;
 
-import java.net.MalformedURLException;
+import java.net.URISyntaxException;
 import java.util.HashMap;
 
 /**
@@ -126,7 +126,7 @@
         String url = null;
         try {
             url = JspUtil.createURL(_href, _action, null, _scopeId, _params, dgm.getJspContext());
-        } catch (MalformedURLException mue) {
+        } catch (URISyntaxException mue) {
             /* todo: real, tag based error reporting */
             if (_logger.isErrorEnabled())
                 _logger.error("Exception creating URL with href " + _href + " action " + _action, mue);

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=109309&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractClassicTag.java&r1=109308&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractClassicTag.java&r2=109309
==============================================================================
--- 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	Tue Nov 30 23:09:49 2004
@@ -17,12 +17,9 @@
  */
 package org.apache.beehive.netui.tags;
 
-import org.apache.beehive.netui.pageflow.util.URLRewriterService;
+import org.apache.beehive.netui.core.urls.URLRewriterService;
 import org.apache.beehive.netui.script.ExpressionEvaluationException;
 import org.apache.beehive.netui.script.ExpressionEvaluator;
-import org.apache.beehive.netui.script.ExpressionEvaluatorFactory;
-import org.apache.beehive.netui.script.ExpressionUpdateException;
-import org.apache.beehive.netui.script.common.ImplicitObjectBean;
 import org.apache.beehive.netui.script.common.ImplicitObjectUtil;
 import org.apache.beehive.netui.tags.naming.FormDataNameInterceptor;
 import org.apache.beehive.netui.tags.naming.IndexedNameInterceptor;
@@ -36,8 +33,6 @@
 import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.PageContext;
 import javax.servlet.jsp.tagext.BodyTagSupport;
-import javax.servlet.jsp.tagext.Tag;
-import javax.servlet.jsp.tagext.JspTag;
 import javax.servlet.jsp.tagext.SimpleTagSupport;
 import java.util.*;
 

Copied: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/PageFlowTagUtils.java (from r109234, incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/PageflowTagUtils.java)
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/PageFlowTagUtils.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/PageflowTagUtils.java&r1=109234&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/PageFlowTagUtils.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/PageflowTagUtils.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/PageFlowTagUtils.java	Tue Nov 30 23:09:49 2004
@@ -15,428 +15,174 @@
  *
  * $Header:$
  */
-package org.apache.beehive.netui.pageflow.util;
+package org.apache.beehive.netui.tags;
 
-//java imports
-import java.net.URLEncoder;
-import java.net.MalformedURLException;
-import java.util.Map;
-import java.util.Iterator;
-
-//internal imports
+import org.apache.beehive.netui.core.urls.MutableURI;
+import org.apache.beehive.netui.core.urls.URLRewriter;
+import org.apache.beehive.netui.core.urls.URLRewriterService;
 import org.apache.beehive.netui.pageflow.FlowController;
 import org.apache.beehive.netui.pageflow.FlowControllerFactory;
+import org.apache.beehive.netui.pageflow.PageFlowConstants;
+import org.apache.beehive.netui.pageflow.PageFlowUtils;
+import org.apache.beehive.netui.pageflow.SecurityProtocol;
 import org.apache.beehive.netui.pageflow.internal.InternalUtils;
 
-import org.apache.beehive.netui.util.logging.Logger;
-import org.apache.beehive.netui.util.FileUtils;
-
-//external imports
+import java.util.Map;
 import javax.servlet.jsp.PageContext;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletRequest;
 
-import org.apache.struts.config.ModuleConfig;
-import org.apache.struts.config.ForwardConfig;
-import org.apache.struts.Globals;
-import org.apache.struts.util.MessageResources;
-import org.apache.struts.util.RequestUtils;
-
-import static org.apache.beehive.netui.pageflow.PageFlowConstants.ACTION_EXTENSION;
-
 
 /**
  * @exclude
- */ 
-public class PageflowTagUtils
+ */
+public class PageFlowTagUtils
 {
-    private static final Logger logger = Logger.getInstance( PageflowTagUtils.class );
-
-    /**
-     * The message resources for this package.
-     */
-    private static MessageResources messages =
-        MessageResources.getMessageResources("org.apache.struts.util.LocalStrings");
-
-    public static String getRewrittenFormAction(HttpServletRequest request, String action, PageContext pageContext)
-    {
-        HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
-        String qualifiedAction = PageflowTagUtils.qualifiedAction(pageContext.getServletContext(),action);
-        String actionUrl = createActionURL(request, qualifiedAction);
-
-        actionUrl = prepareActionUrl(pageContext, actionUrl);
-
-        return response.encodeURL(actionUrl);
-    }
-
-    public static String prepareActionUrl(PageContext pageContext, String url)
+    public static MutableURI rewriteActionURL( PageContext pageContext, String action, Map params, String location )
+            throws java.net.URISyntaxException
     {
         ServletContext servletContext = pageContext.getServletContext();
         ServletRequest request = pageContext.getRequest();
-        HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
+        HttpServletResponse response = ( HttpServletResponse ) pageContext.getResponse();
+        String qualifiedAction = InternalUtils.qualifiedAction( servletContext, action );
+        String actionUrl = InternalUtils.createActionURL( ( HttpServletRequest ) request, qualifiedAction );
+        MutableURI uri = new MutableURI( actionUrl );
 
-        String templateType = URLRewriter.ACTION_UNSECURE;
+        if ( params != null )
+        {
+            String encoding = response.getCharacterEncoding();
+            uri.addParameters( params, false, encoding );
+        }
 
-        if (URLRewriterService.needsSecure(request, servletContext, url, true))
-            templateType = URLRewriter.ACTION_SECURE;
+        if ( location != null ) { uri.setFragment( location ); }
 
-        url = URLRewriterService.rewriteURL(servletContext, request, response, url, templateType);
+        boolean needsToBeSecure = needsSecure( servletContext, request, actionUrl, true );
+        URLRewriterService.rewriteURL( servletContext, request, response, uri,
+                                       URLRewriter.Type.ACTION, needsToBeSecure );
 
-        return response.encodeURL(url);
+        return uri;
     }
 
-    public static String prepareResourceUrl(PageContext pageContext, String url)
+    public static MutableURI rewriteResourceURL( PageContext pageContext, String url, Map params, String location )
+            throws java.net.URISyntaxException
     {
-        if ( FileUtils.isAbsoluteURI(url) )
+        HttpServletResponse response = ( HttpServletResponse ) pageContext.getResponse();
+        MutableURI uri = new MutableURI( url );
+        if ( params != null )
         {
-            return url;
+            String encoding = response.getCharacterEncoding();
+            uri.addParameters( params, false, encoding );
         }
-        
-        ServletContext servletContext = pageContext.getServletContext();
-        HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
-        HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
 
+        if ( location != null ) { uri.setFragment( location ); }
 
-        if (!url.startsWith("/"))
-        {
-            String reqUri = request.getRequestURI();
-            String path = reqUri.substring(0, reqUri.lastIndexOf("/") + 1);
-            url = path + url;
-        }
-
-        String templateType = URLRewriter.RESOURCE_UNSECURE;
-
-        if (URLRewriterService.needsSecure(request, servletContext, url, true))
-            templateType = URLRewriter.RESOURCE_SECURE;
-
-        url = URLRewriterService.rewriteURL(servletContext, request, response, url, templateType);
-
-        return response.encodeURL(url);
-    }
+        if ( uri.isAbsolute() ) { return uri; }
 
-    public static String createActionURL(HttpServletRequest servletRequest, String qualifiedAction)
-    {
-        String pageURI = InternalUtils.getDecodedURI( servletRequest );
-        int lastSlash = pageURI.lastIndexOf( '/' );
-        if ( lastSlash != -1 )
+        HttpServletRequest request = ( HttpServletRequest ) pageContext.getRequest();
+        if ( !url.startsWith( "/" ) && !url.equals( "" ) )
         {
-            StringBuilder value = new StringBuilder(qualifiedAction.length() + 16);
-            value.append( pageURI.substring( 0, lastSlash ) );
-            value.append(qualifiedAction);
-            return value.toString();
+            String reqUri = request.getRequestURI();
+            String path = reqUri.substring( 0, reqUri.lastIndexOf( '/' ) + 1 );
+            uri.setPath( path + uri.getPath() );
         }
-        return qualifiedAction;
-    }
 
-    public static String createActionPath(HttpServletRequest request, String qualifiedAction)
-    {
+        ServletContext servletContext = pageContext.getServletContext();
+        boolean needsToBeSecure = needsSecure( servletContext, request, url, true );
+        URLRewriterService.rewriteURL( servletContext, request, response, uri,
+                                       URLRewriter.Type.RESOURCE, needsToBeSecure );
 
-        ModuleConfig appConfig = (ModuleConfig) request.getAttribute(Globals.MODULE_KEY);
-        if (appConfig != null)
-        {
-            StringBuilder value = new StringBuilder(qualifiedAction.length() + 16);
-            value.append(appConfig.getPrefix());
-            value.append(qualifiedAction);
-            return value.toString();
-        }
-        return qualifiedAction;
+        return uri;
     }
 
-    public static String qualifiedAction(ServletContext servletContext, String action)
+    public static boolean isAction( HttpServletRequest request, HttpServletResponse response,
+                                    ServletContext servletContext, String action )
     {
-        StringBuilder sb = new StringBuilder(32);
-
-        // Use our servlet mapping, if one is specified
-        String servletMapping = (String) servletContext.getAttribute(Globals.SERVLET_KEY);
-        if (servletMapping != null)
+        boolean isAnAction = true;
+        FlowController flowController = InternalUtils.getCurrentPageFlow( request, false );
+        if ( flowController != null )
         {
-            String queryString = null;
-            int question = action.indexOf("?");
-            if (question >= 0)
-            {
-                queryString = action.substring(question);
-            }
-            String actionMapping = URLRewriterService.getActionMappingName(action);
-            if (servletMapping.startsWith("*."))
-            {
-                sb.append(actionMapping);
-                sb.append(servletMapping.substring(1));
-            }
-            else if (servletMapping.endsWith("/*"))
-            {
-                sb.append(servletMapping.substring(0, servletMapping.length() - 2));
-                sb.append(actionMapping);
-            }
-            else if (servletMapping.equals("/"))
+            String checkAction = action;
+            if ( checkAction.startsWith( "/" ) )
             {
-                sb.append(actionMapping);
+                checkAction = checkAction.substring( 1 );
             }
-            if (queryString != null) {
-                sb.append(queryString);
-            }
-        }
-
-        // Otherwise, assume extension mapping is in use and extension is
-        // already included in the action property
-        else
-        {
-            if (!action.startsWith("/"))
+            if ( checkAction.endsWith( PageFlowConstants.ACTION_EXTENSION ) )
             {
-                sb.append("/");
+                checkAction = checkAction.substring( 0, checkAction.length() - PageFlowConstants.ACTION_EXTENSION.length() );
             }
-            sb.append(action);
-        }
-        return sb.toString();
-    }
-
-    public static boolean isAction(HttpServletRequest request, HttpServletResponse response, ServletContext servletContext, String action)
-    {
-        boolean isAnAction = true;
-        FlowController flowController = InternalUtils.getCurrentPageFlow(request, false);
-        if (flowController != null)
-        {
-            String checkAction = action;
-            if (checkAction.startsWith("/"))
-                checkAction = checkAction.substring(1);
-            if (checkAction.endsWith(ACTION_EXTENSION))
-                checkAction = checkAction.substring(0, checkAction.length() - ACTION_EXTENSION.length());
-            isAnAction = flowController.isAction(checkAction);
+            isAnAction = flowController.isAction( checkAction );
 
-            if (!isAnAction)
+            if ( !isAnAction )
             {
                 FlowController globalController =
                         FlowControllerFactory.getSharedFlowForRequest( request, response, servletContext );
-                if (globalController != null)
-                    isAnAction = globalController.isAction(checkAction);
+                if ( globalController != null )
+                {
+                    isAnAction = globalController.isAction( checkAction );
+                }
             }
         }
 
         return isAnAction;
     }
 
-
-    // @struts : from org.apache.struts.util.RequestUtils RC 1.1
-    public static String computeURL
-    (
-        PageContext pageContext,
-        String forward,
-        String href,
-        String page,
-        Map params,
-        String anchor,
-        boolean redirect)
-        throws MalformedURLException {
-
-        return computeURL(pageContext, forward, href, page, null, params,
-			  anchor, redirect);
-    }
-
-    // @struts : from org.apache.struts.util.RequestUtils RC 1.1
-    public static String computeURL(
-        PageContext pageContext,
-        String forward,
-        String href,
-        String page,
-        String action,
-        Map params,
-        String anchor,
-        boolean redirect)
-        throws MalformedURLException
+    /**
+     * Tell whether a given URI should be written to be secure.
+     *
+     * @param request          the current HttpServletRequest.
+     * @param context          the current ServletContext.
+     * @param uri              the URI to check.
+     * @param stripContextPath if <code>true</code>, strip the webapp context path from the URI before
+     *                         processing it.
+     * @return <code>true</code> when:
+     *         <ul>
+     *         <li>the given URI is configured in the deployment descriptor to be secure (according to
+     *         {@link org.apache.beehive.netui.core.SecurityProtocol}), or
+     *         <li>the given URI is not configured in the deployment descriptor, and the current request
+     *         is secure ({@link javax.servlet.http.HttpServletRequest#isSecure} returns
+     *         <code>true</code>).
+     *         </ul>
+     *         <code>false</code> when:
+     *         <ul>
+     *         <li>the given URI is configured explicitly in the deployment descriptor to be unsecure
+     *         (according to {@link org.apache.beehive.netui.core.SecurityProtocol}), or
+     *         <li>the given URI is not configured in the deployment descriptor, and the current request
+     *         is unsecure ({@link javax.servlet.http.HttpServletRequest#isSecure} returns
+     *         <code>false</code>).
+     *         </ul>
+     */
+    public static boolean needsSecure( ServletContext context, ServletRequest request,
+                                       String uri, boolean stripContextPath )
     {
-
-        String encoding = pageContext.getResponse().getCharacterEncoding();
-
-        // Validate that exactly one specifier was included
-        int n = 0;
-        if (forward != null) {
-            n++;
-        }
-        if (href != null) {
-            n++;
-        }
-        if (page != null) {
-            n++;
-        }
-        if (action != null) {
-            n++;
-        }
-        if (n != 1) {
-            throw new MalformedURLException(messages.getMessage("computeURL.specifier"));
-        }
-
-        HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
-
-        // Look up the module configuration for this request
-        ModuleConfig config =
-            (ModuleConfig) request.getAttribute(Globals.MODULE_KEY);
-        if (config == null) { // Backwards compatibility hack
-            config =
-                (ModuleConfig) pageContext.getServletContext().getAttribute(Globals.MODULE_KEY);
-            InternalUtils.setCurrentModule( config, request );
-        }
-
-        // Calculate the appropriate URL
-        StringBuilder url = new StringBuilder(32);
-        if (forward != null) {
-            ForwardConfig fc = config.findForwardConfig(forward);
-            if (fc == null) {
-                throw new MalformedURLException(messages.getMessage("computeURL.forward", forward));
-            }
-            if (fc.getRedirect()) {
-                redirect = true;
-            }
-            if (fc.getPath().startsWith("/")) {
-                url.append(request.getContextPath());
-                url.append(RequestUtils.forwardURL(request, fc));
-            } else {
-                url.append(fc.getPath());
+        // Get the web-app relative path for security check
+        String secureCheck = uri;
+        if ( stripContextPath )
+        {
+            String contextPath = ( ( HttpServletRequest ) request ).getContextPath();
+            if ( secureCheck.startsWith( contextPath ) )
+            {
+                secureCheck = secureCheck.substring( contextPath.length() );
             }
-        } else if (href != null) {
-            url.append(href);
-        } else if (action != null) {
-            url.append(RequestUtils.getActionMappingURL(action, pageContext));
-
-        } else /* if (page != null) */ {
-            url.append(request.getContextPath());
-            url.append(RequestUtils.pageURL(request, page));
         }
 
-        // Add anchor if requested (replacing any existing anchor)
-        if (anchor != null) {
-            String temp = url.toString();
-            int hash = temp.indexOf('#');
-            if (hash >= 0) {
-                url.setLength(hash);
-            }
-            url.append('#');
-            url.append(encodeURL(anchor,encoding));
+        boolean secure = false;
+        if ( secureCheck.indexOf( '?' ) > -1 )
+        {
+            secureCheck = secureCheck.substring( 0, secureCheck.indexOf( '?' ) );
         }
 
-        // Add dynamic parameters if requested
-        if ((params != null) && (params.size() > 0)) {
-            addParameters(url,encoding,redirect,params);
+        SecurityProtocol sp = PageFlowUtils.getSecurityProtocol( secureCheck, context, ( HttpServletRequest ) request );
+        if ( sp.equals( SecurityProtocol.UNSPECIFIED ) )
+        {
+            secure = request.isSecure();
         }
-
-        return (url.toString());
-    }
-
-    //
-    public static void addParameters(StringBuilder url,String encoding,
-                                     boolean redirect,Map params)
-    {
-        String anchor;
-        // Add dynamic parameters if requested
-        if ((params != null) && (params.size() > 0)) {
-
-            // Save any existing anchor
-            String temp = url.toString();
-            int hash = temp.indexOf('#');
-            if (hash >= 0) {
-                anchor = temp.substring(hash + 1);
-                url.setLength(hash);
-                temp = url.toString();
-            } else {
-                anchor = null;
-            }
-
-            // Define the parameter separator
-            String separator = "&amp;";
-            if (redirect) {
-                separator = "&";
-            }
-
-            // Add the required request parameters
-            boolean question = temp.indexOf('?') >= 0;
-            Iterator keys = params.keySet().iterator();
-            while (keys.hasNext()) {
-                String key = (String) keys.next();
-                Object value = params.get(key);
-                if (value == null) {
-                    if (!question) {
-                        url.append('?');
-                        question = true;
-                    } else {
-                        url.append(separator);
-                    }
-                    url.append(encodeURL(key,encoding));
-                    url.append('='); // Interpret null as "no value"
-                } else if (value instanceof String) {
-                    if (!question) {
-                        url.append('?');
-                        question = true;
-                    } else {
-                        url.append(separator);
-                    }
-                    url.append(encodeURL(key,encoding));
-                    url.append('=');
-                    url.append(encodeURL((String) value,encoding));
-                } else if (value instanceof String[]) {
-                    String values[] = (String[]) value;
-                    for (int i = 0; i < values.length; i++) {
-                        if (!question) {
-                            url.append('?');
-                            question = true;
-                        } else {
-                            url.append(separator);
-                        }
-                        url.append(encodeURL(key,encoding));
-                        url.append('=');
-                        url.append(encodeURL(values[i],encoding));
-                    }
-                } else /* Convert other objects to a string */ {
-                    if (!question) {
-                        url.append('?');
-                        question = true;
-                    } else {
-                        url.append(separator);
-                    }
-                    url.append(encodeURL(key,encoding));
-                    url.append('=');
-                    url.append(encodeURL(value.toString(),encoding));
-                }
-            }
-
-            // Re-add the saved anchor (if any)
-            if (anchor != null) {
-                url.append('#');
-                url.append(encodeURL(anchor,encoding));
-            }
+        else
+        {
+            secure = sp.equals( SecurityProtocol.SECURE );
         }
-    }
-
 
-    // @struts : from org.apache.struts.util.RequestUtils RC 1.1
-    // This has been modified from the strut to assume 1.4 because we ship 
-    // with that.
-    public static String encodeURL(String url, String encoding)
-    {
-        String encodedURL = null;
-        try {
-            encodedURL = URLEncoder.encode(url,encoding);
-        }
-        catch (java.io.UnsupportedEncodingException e) {
-            logger.error( "Unsupported encoding:" + encoding, e );
-            // try this in utf-8 and log the exception
-            try {
-                encodedURL = URLEncoder.encode(url,"UTF-8");
-            }
-            catch (java.io.UnsupportedEncodingException ignore) {}
-        }
-        return encodedURL;
-    }
-    
-    /**
-     * Add a parameter to the given URL.
-     * 
-     * @param url the URL to which to append. 
-     * @param paramName the name of the parameter to add.
-     * @param paramVal the value of the parameter to add.
-     * @return the URL, with the given parameter added.
-     */ 
-    public static String addParam(String url, String paramName, String paramVal)
-    {
-        return url + (url.indexOf('?') != -1 ? '&' : '?') + paramName + '=' + paramVal;
+        return secure;
     }
 }

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=109309&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/AnchorBase.java&r1=109308&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/AnchorBase.java&r2=109309
==============================================================================
--- 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	Tue Nov 30 23:09:49 2004
@@ -1,572 +1,523 @@
-package org.apache.beehive.netui.tags.html;
-
-import org.apache.beehive.netui.tags.rendering.*;
-import org.apache.beehive.netui.tags.ByRef;
-import org.apache.beehive.netui.tags.IScriptReporter;
-import org.apache.beehive.netui.tags.HtmlUtils;
-import org.apache.beehive.netui.util.Bundle;
-import org.apache.beehive.netui.util.ParamHelper;
-import org.apache.beehive.netui.util.FileUtils;
-import org.apache.beehive.netui.util.logging.Logger;
-import org.apache.beehive.netui.pageflow.util.PageflowTagUtils;
-import org.apache.beehive.netui.pageflow.util.URLRewriter;
-import org.apache.beehive.netui.pageflow.util.URLRewriterService;
-import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
-
-import javax.servlet.jsp.JspException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletRequest;
-import java.util.HashMap;
-import java.util.Map;
-import java.net.MalformedURLException;
-
-/**
- * This is the base class that provides most of the features necessary to create an anchor and an area. The Anchor
- * and Area tags are created as subclasses of this tag.  The Area tag is really a subset of the features, so certain
- * attributes are not defined here, even though the backing fields are defined here and the utility code knows them.
- * 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 URLParams
-{
-    private static final String REQUIRED_ATTR = "href, action, linkName, clientAction";
-    private static final Logger logger = Logger.getInstance(AnchorBase.class);
-
-    protected AnchorTag.State _state = new AnchorTag.State();
-    protected String _linkName;     // name of the link
-    protected String _clientAction; // The client action (javascript)
-
-    private String _action;
-    private String _href;
-    private String _scope;        // target scope; see comments on setScope()
-    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?
-
-    /**
-     * Base support for the attribute tag.  This is overridden to prevent setting the <code>href</code>
-     * attribute.
-     * @param name  The name of the attribute.  This value may not be null or the empty string.
-     * @param value The value of the attribute.  This may contain an expression.
-     * @param facet The name of a facet to which the attribute will be applied.  This is optional.
-     * @throws JspException A JspException may be thrown if there is an error setting the attribute.
-     */
-    public void setAttribute(String name, String value, String facet)
-            throws JspException
-    {
-        if (name != null && name.equals(HREF)) {
-            String s = Bundle.getString("Tags_AttributeMayNotBeSet", new Object[]{name});
-            registerTagError(s, null);
-        }
-        super.setAttribute(name, value, facet);
-    }
-
-    /**
-     * Sets <code>shape</code> attribute for the area.
-     * @param shape - the window target.
-     * @jsptagref.attributedescription The shape.
-     * @jsptagref.databindable false
-     * @jsptagref.attributesyntaxvalue <i>string_shape</i>
-     * @netui:attribute required="false"  rtexprvalue="true"
-     * description="The shape."
-     * @netui.tldx:attribute category="misc"
-     */
-    public void setShape(String shape)
-    {
-        _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, SHAPE, shape);
-    }
-
-    /**
-     * Sets <code>coords</code> attribute for the area.
-     * @param coords - the window target.
-     * @jsptagref.attributedescription The coordinates.
-     * @jsptagref.databindable false
-     * @jsptagref.attributesyntaxvalue <i>string_coordinates</i>
-     * @netui:attribute required="false"  rtexprvalue="true"
-     * description="The coordinates."
-     * @netui.tldx:attribute category="misc"
-     */
-    public void setCoords(String coords)
-    {
-        _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, COORDS, coords);
-    }
-
-    /**
-     * Set the name of the action for the Area.
-     * @param action - the name of the action to set for the Area.
-     * @jsptagref.attributedescription The action method to invoke.  The action method must be in the Controller file
-     * of the Page Flow directory.
-     * @jsptagref.databindable false
-     * @jsptagref.attributesyntaxvalue <i>string_action</i>
-     * @netui:attribute required="false" rtexprvalue="true"
-     * description="The action method to invoke.  The action method must be in the Controller file of the Page Flow directory."
-     * @netui.tldx:attribute reftype="netui-action-url" category="general"
-     */
-    public void setAction(String action)
-            throws JspException
-    {
-        _action = setRequiredValueAttribute(action, "action");
-    }
-
-    /**
-     * Sets the href of the Anchor. This attribute will accept the empty String as a legal value.
-     * @param href - the hyperlink URI for the Area.
-     * @jsptagref.attributedescription The URL to go to.
-     * @jsptagref.databindable false
-     * @jsptagref.attributesyntaxvalue <i>string_href</i>
-     * @netui:attribute required="false" rtexprvalue="true"
-     * description="The URL to go to."
-     * @netui.tldx:attribute propertyclass="workshop.jspdesigner.properties.URIPropertyClass"
-     * reftype="url"
-     */
-    public void setHref(String href)
-            throws JspException
-    {
-        _href = href;
-    }
-
-    /**
-     * Sets the anchor to be added to the end of the generated hyperlink.
-     * @param location - the name of the location anchor.
-     * @jsptagref.attributedescription Location within the URI to visit.
-     * @jsptagref.databindable false
-     * @jsptagref.attributesyntaxvalue <i>string_location</i>
-     * @netui:attribute required="false"  rtexprvalue="true"
-     * description="Location within the URI to visit."
-     * @netui.tldx:attribute
-     */
-    public void setLocation(String location)
-    {
-        _location = setNonEmptyValueAttribute(location);
-    }
-
-    /**
-     * Set the name of the action for the Anchor.
-     * @param scope - the name of the action to set for the Anchor
-     * @jsptagref.attributedescription The scope
-     * @jsptagref.databindable false
-     * @jsptagref.attributesyntaxvalue <i>string_scope</i>
-     * @netui:attribute required="false" rtexprvalue="true"
-     * description="The scope"
-     * @netui.tldx:attribute category="general"
-     */
-    public void setScope(String scope)
-    {
-        _scope = setNonEmptyValueAttribute(scope);
-    }
-
-
-    /**
-     * Sets the formSubmit indicator.
-     * @param formSubmit - whether or not the enclosing Form should be submitted.
-     * @jsptagref.attributedescription Boolean.  If <code>formSubmit</code> is set to true, and the &lt;netui:anchor> tag
-     * is within a &lt;netui:form> tag,
-     * then the form data will be submitted to the method named in the
-     * &lt;netui:form> tag's <code>action</code> attribute.
-     * @jsptagref.databindable false
-     * @jsptagref.attributesyntaxvalue <i>boolean_formSubmit</i>
-     * @netui:attribute required="false" rtexprvalue="true" type="boolean"
-     * description="If formSubmit is set to true, and the <netui:anchor> tag
-     * is within a <netui:form> tag,
-     * then the form data will be submitted to the method named in the
-     * <netui:form> tag's action attribute."
-     * @netui.tldx:attribute
-     */
-    public void setFormSubmit(boolean formSubmit)
-    {
-        _formSubmit = formSubmit;
-    }
-
-
-    /**
-     * Sets the tabIndex of the rendered html tag.
-     * @param tabindex - the tab index.
-     * @jsptagref.attributedescription The tabIndex of the rendered HTML tag.  This attribute determines the position of the
-     * rendered HTML tag in the sequence of tags that the user may advance through by pressing the TAB key.
-     * @jsptagref.databindable false
-     * @jsptagref.attributesyntaxvalue <i>string_tabIndex</i>
-     * @netui:attribute required="false"  rtexprvalue="true" type="int"
-     * description="The tabIndex of the rendered HTML tag.  This attribute determines the position of the
-     * rendered HTML tag in the sequence of tags that the user may advance through by pressing the TAB key."
-     * @netui.tldx:attribute category="misc"
-     */
-    public void setTabindex(int tabindex)
-    {
-        _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, TABINDEX, Integer.toString(tabindex));
-    }
-
-
-    /**
-     * Sets the accessKey attribute value.  This should key value of the
-     * keyboard navigation key.  It is recommended not to use the following
-     * values because there are often used by browsers <code>A, C, E, F, G,
-     * H, V, left arrow, and right arrow</code>.
-     * @param accessKey - the accessKey value.
-     * @jsptagref.attributedescription The keyboard navigation key for the element.
-     * The following values are not recommended because they
-     * are often used by browsers: <code>A, C, E, F, G,
-     * H, V, left arrow, and right arrow</code>
-     * @jsptagref.databindable false
-     * @jsptagref.attributesyntaxvalue <i>string_accessKey</i>
-     * @netui:attribute required="false" rtexprvalue="true"  type="char"
-     * description=" The keyboard navigation key for the element.
-     * The following values are not recommended because they
-     * are often used by browsers: A, C, E, F, G,
-     * H, V, left arrow, and right arrow."
-     * @netui.tldx:attribute category="misc"
-     */
-    public void setAccessKey(char accessKey)
-    {
-        if (accessKey == 0x00)
-            return;
-        _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, ACCESSKEY, Character.toString(accessKey));
-    }
-
-    /**
-     * Sets the onBlur javascript event.
-     * @param onblur - the onBlur event.
-     * @jsptagref.attributedescription The onBlur JavaScript event.
-     * @jsptagref.databindable false
-     * @jsptagref.attributesyntaxvalue <i>string_onBlur</i>
-     * @netui:attribute required="false" rtexprvalue="true"
-     * description="The onBlur JavaScript event."
-     * @netui.tldx:attribute propertyclass="workshop.jspdesigner.properties.EventPropertyClass" category="event"
-     */
-    public void setOnBlur(String onblur)
-    {
-        _state.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONBLUR, onblur);
-    }
-
-    /**
-     * Sets the onFocus javascript event.
-     * @param onfocus - the onFocus event.
-     * @jsptagref.attributedescription The onFocus JavaScript event.
-     * @jsptagref.databindable false
-     * @jsptagref.attributesyntaxvalue <i>string_onFocus</i>
-     * @netui:attribute required="false" rtexprvalue="true"
-     * description="The onFocus JavaScript event."
-     * @netui.tldx:attribute propertyclass="workshop.jspdesigner.properties.EventPropertyClass" category="event"
-     */
-    public void setOnFocus(String onfocus)
-    {
-        _state.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONFOCUS, onfocus);
-    }
-
-    //**************************** Helper Routines  *********************************************
-
-    /**
-     * Adds a URL parameter to the generated hyperlink.
-     * @param name  - the name of the parameter to be added.
-     * @param value - the value of the parameter to be added (a String or String[]).
-     */
-    public void addParameter(String name, Object value) throws JspException
-    {
-        if (_params == null) {
-            _params = new HashMap();
-        }
-        ParamHelper.addParam(_params, name, value);
-    }
-
-    /**
-     * This method will create the &lt;a> portion of an anchor.  It is called by subclasses, for example, the
-     * <code>ImageAnchor</code> relies on this code to generate the  &lt;a>.
-     * @param scriptRef a <code>ByRef&lt;String></code> that will contain any JavaScript that may need to be added
-     *               to the generated HTML response.
-     * @return a boolean value indicating if an error occur creating the anchor.
-     * @throws JspException
-     */
-    protected final boolean createAnchorBeginTag(HttpServletRequest request, ByRef scriptRef,
-                                                 TagRenderingBase trb, AbstractRenderAppender writer)
-            throws JspException
-    {
-        int have = 0;
-        String formAction = null;
-        String idScript = null;
-
-        if (_formSubmit)
-            _form = getNearestForm();
-
-        HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
-        ServletContext ctxt = pageContext.getServletContext();
-        JavaScriptUtils jsu = getJavaScriptUtils(request);
-
-        // check the parameters that the user provided
-        if (_href != null) have++;
-        if (_action != null) have++;
-        if (_clientAction != null) have++;
-        if (_linkName != null) have++;
-
-        String tagId = getTagId();
-
-        // if only the _linkName or _tagId is set then we are creating the name attribute only.
-        if (have == 0 && tagId != null) {
-            return createNameAnchor(request, tagId, trb);
-        }
-
-        // if the anchor is submitting a consider this a submit level problem
-        // set the action to the form action.
-        if (_formSubmit == true) {
-            formAction = getFormAction();
-            if ((formAction != null) && (have == 0)) {
-                have++;
-            }
-            if (_action == null)
-                _action = formAction;
-        }
-
-        // if we have not specified a destination or we've specified too many
-        // then we need to report an error.
-        if (have == 0 || have > 1) {
-            String s = Bundle.getString("Tags_Anchor_InvalidAnchorURI", new Object[]{REQUIRED_ATTR});
-            registerTagError(s, null);
-            return false;
-        }
-
-        if (_linkName != null) {
-            return createPageAnchor(request, trb);
-        }
-
-        // report that action is not an action
-        if ((_action != null) && (!PageflowTagUtils.isAction(request, response, ctxt, _action))) {
-            String s = null;
-            if (_action.equals("")) {
-                s = Bundle.getString("Tags_NullBadAction", null);
-            }
-            else {
-                s = Bundle.getString("Tags_BadAction", _action);
-            }
-            registerTagError(s, null);
-        }
-
-        String internalHref = _state.href;
-        boolean absoluteUrl = false;
-
-        // we assume that tagId will over have override id if both
-        // are defined.
-        if (tagId != null) {
-            idScript = renderTagId(_state, null, true, false);
-        }
-        else {
-            _state.id = id;
-        }
-
-        // Special case for name anchors
-        if (_clientAction != null) {
-            _state.href = "";
-        }
-        else {
-            // Generate the opening anchor element
-            String type = URLRewriter.ACTION_UNSECURE;
-
-            if (_action != null) {
-                // simply set this to the result of mangling the action
-                String qualifiedAction = PageflowTagUtils.qualifiedAction(ctxt, _action);
-                String actionUrl = PageflowTagUtils.createActionPath(request, qualifiedAction);
-                if (URLRewriterService.needsSecure(request, ctxt, actionUrl, false))
-                    type = URLRewriter.ACTION_SECURE;
-                internalHref = PageflowTagUtils.createActionURL(request, qualifiedAction);
-            }
-            else if (_href != null) {
-                internalHref = _href;
-                if (FileUtils.isAbsoluteURI(internalHref)) {
-                    absoluteUrl = true;
-                }
-                else if (!internalHref.startsWith("/")) {
-                    // for internal hrefs, we need to see if we need to secure the request
-                    if (!_href.equals("")) {
-                        String reqUri = request.getRequestURI();
-                        String path = reqUri.substring(0, reqUri.lastIndexOf("/") + 1);
-                        internalHref = path + internalHref;
-
-                        // is this a secure operation?
-                        if ((!absoluteUrl) && (URLRewriterService.needsSecure(request, ctxt, internalHref, true)))
-                            type = URLRewriter.ACTION_SECURE;
-                    }
-                }
-            }
-
-            // Add the jpfScopeID parameter, if the scope attribute is present.
-            if (_scope != null) {
-                if (_params == null) {
-                    _params = new HashMap();
-                }
-                _params.put(ScopedServletUtils.SCOPE_ID_PARAM, _scope);
-            }
-
-            if (!absoluteUrl) {
-                internalHref = calculateURL(internalHref, _location);
-            }
-            else {
-                if ((_params != null) && (_params.size() > 0)) {
-                    StringBuilder sb = new StringBuilder(internalHref);
-                    String encoding = response.getCharacterEncoding();
-                    PageflowTagUtils.addParameters(sb, encoding, false, _params);
-                    internalHref = sb.toString();
-                }
-            }
-
-            if (internalHref == null) {
-                if (hasErrors()) {
-                    return false;
-                }
-            }
-
-            if (!absoluteUrl) {
-                internalHref = URLRewriterService.rewriteURL(ctxt, request, response, internalHref, type);
-                internalHref = qualifyUrlToContext(internalHref);
-            }
-            _state.href = internalHref;
-        }
-
-        // We need to combine the onclick features
-        IScriptReporter sr = getScriptReporter();
-        if (sr != null && sr.isRunAtClient()) {
-            if (_clientAction == null) {
-                if (_state.onClick == null) {
-                    _state.onClick = "NetUIAnchorRewriter(this);";
-                }
-                else {
-                    String click = HtmlUtils.escapeEscapes(_state.onClick);
-                    String entry = JavaScriptUtils.getString("createAnchorRewriterOnClickExists",
-                            new Object[]{click});
-                    _state.onClick = entry;
-                }
-            }
-            else {
-                //@todo: we need to support onclick chaining here also...
-                String action = HtmlUtils.escapeEscapes(_clientAction);
-                String entry = JavaScriptUtils.getString("netuiAction",
-                        new Object[]{action});
-                _state.onClick = entry;
-            }
-        }
-
-        // if the user override the onclick we will ignor this
-        if (_state.onClick == null && _formSubmit && formAction != null) {
-            String realFormName = getRealFormName();
-            _state.onClick = jsu.writeAnchorFormSubmitAction(realFormName, internalHref);
-            if (_form != null)
-                _form.generateRealName();
-        }
-
-        if (hasErrors())
-            return false;
-
-        trb.doStartTag(writer, _state);
-
-        //Emit javascript if this anchor needs to sumbit the form
-        if (_formSubmit && formAction != null || idScript != null) {
-            StringBuilder script = new StringBuilder(32);
-            StringBuilderRenderAppender scriptWriter = new StringBuilderRenderAppender(script);
-
-            if (_formSubmit && formAction != null)
-                jsu.writeAnchorFormSubmit(getScriptReporter(),scriptWriter);
-            if (idScript != null)
-                scriptWriter.append(idScript);
-            scriptRef.setRef(script.toString());
-        }
-
-        // create the javaScript
-        return true;
-    }
-
-    /**
-     * @param tagId
-     * @return
-     */
-    private boolean createNameAnchor(ServletRequest req, String tagId, TagRenderingBase trb)
-    {
-        WriteRenderAppender writer = new WriteRenderAppender(pageContext);
-        _state.name = tagId;
-        trb = TagRenderingBase.Factory.getRendering(TagRenderingBase.ANCHOR_TAG, req);
-        trb.doStartTag(writer, _state);
-        return !hasErrors();
-    }
-
-    private boolean createPageAnchor(ServletRequest req, TagRenderingBase trb)
-    {
-        _linkName = _linkName.trim();
-        if (_linkName.charAt(0) != '#') {
-            _state.href = "#" + _linkName;
-        }
-        else
-            _state.href = _linkName;
-
-        WriteRenderAppender writer = new WriteRenderAppender(pageContext);
-        trb = TagRenderingBase.Factory.getRendering(TagRenderingBase.ANCHOR_TAG, req);
-        trb.doStartTag(writer, _state);
-        return !hasErrors();
-    }
-
-    /**
-     * Return the complete URL to which this hyperlink will direct the user.
-     * @param href
-     * @param location
-     * @return
-     * @throws JspException
-     */
-    private String calculateURL(String href, String location) throws JspException
-    {
-        String url = null;
-        try {
-            url = PageflowTagUtils.computeURL(pageContext, null, href, null, null, _params, location, true);
-        }
-        catch (MalformedURLException e) {
-            // report the error...
-            logger.error(Bundle.getString("Tags_MalformedURLException"));
-            String s = null;
-            s = Bundle.getString("Tags_Anchor_URLException",
-                    new Object[]{e.getMessage()});
-            registerTagError(s, e);
-        }
-        return url;
-    }
-
-    /**
-     * Return the action attribute for the nearest form.
-     * @return The action attribute of the enclosing form
-     */
-    private String getFormAction()
-    {
-        if (_form != null)
-            return _form.getAction();
-        return null;
-    }
-
-    /**
-     * This will get the real name of the form.  This is set in the
-     * id attribute.
-     * @return The String real name of the containing form.
-     */
-    private String getRealFormName()
-    {
-        if (_form != null) {
-            return _form.getRealName();
-        }
-        return null;
-    }
-
-    /**
-     * Release any acquired resources.
-     */
-    protected void localRelease()
-    {
-        super.localRelease();
-
-        _state.clear();
-        _linkName = null;
-        _clientAction = null;
-
-        _action = null;
-        _href = null;
-        _scope = null;
-        _location = null;
-        _params = null;
-        _form = null;
-        _formSubmit = false;
-    }
-
-}
+package org.apache.beehive.netui.tags.html;
+
+import org.apache.beehive.netui.core.urls.MutableURI;
+import org.apache.beehive.netui.tags.rendering.*;
+import org.apache.beehive.netui.tags.ByRef;
+import org.apache.beehive.netui.tags.IScriptReporter;
+import org.apache.beehive.netui.tags.HtmlUtils;
+import org.apache.beehive.netui.tags.PageFlowTagUtils;
+import org.apache.beehive.netui.util.Bundle;
+import org.apache.beehive.netui.util.ParamHelper;
+import org.apache.beehive.netui.util.logging.Logger;
+import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletRequest;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * This is the base class that provides most of the features necessary to create an anchor and an area. The Anchor
+ * and Area tags are created as subclasses of this tag.  The Area tag is really a subset of the features, so certain
+ * attributes are not defined here, even though the backing fields are defined here and the utility code knows them.
+ * 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 URLParams
+{
+    private static final String REQUIRED_ATTR = "href, action, linkName, clientAction";
+    private static final Logger logger = Logger.getInstance(AnchorBase.class);
+
+    protected AnchorTag.State _state = new AnchorTag.State();
+    protected String _linkName;     // name of the link
+    protected String _clientAction; // The client action (javascript)
+
+    private String _action;
+    private String _href;
+    private String _scope;        // target scope; see comments on setScope()
+    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?
+
+    /**
+     * Base support for the attribute tag.  This is overridden to prevent setting the <code>href</code>
+     * attribute.
+     * @param name  The name of the attribute.  This value may not be null or the empty string.
+     * @param value The value of the attribute.  This may contain an expression.
+     * @param facet The name of a facet to which the attribute will be applied.  This is optional.
+     * @throws JspException A JspException may be thrown if there is an error setting the attribute.
+     */
+    public void setAttribute(String name, String value, String facet)
+            throws JspException
+    {
+        if (name != null && name.equals(HREF)) {
+            String s = Bundle.getString("Tags_AttributeMayNotBeSet", new Object[]{name});
+            registerTagError(s, null);
+        }
+        super.setAttribute(name, value, facet);
+    }
+
+    /**
+     * Sets <code>shape</code> attribute for the area.
+     * @param shape - the window target.
+     * @jsptagref.attributedescription The shape.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_shape</i>
+     * @netui:attribute required="false"  rtexprvalue="true"
+     * description="The shape."
+     * @netui.tldx:attribute category="misc"
+     */
+    public void setShape(String shape)
+    {
+        _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, SHAPE, shape);
+    }
+
+    /**
+     * Sets <code>coords</code> attribute for the area.
+     * @param coords - the window target.
+     * @jsptagref.attributedescription The coordinates.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_coordinates</i>
+     * @netui:attribute required="false"  rtexprvalue="true"
+     * description="The coordinates."
+     * @netui.tldx:attribute category="misc"
+     */
+    public void setCoords(String coords)
+    {
+        _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, COORDS, coords);
+    }
+
+    /**
+     * Set the name of the action for the Area.
+     * @param action - the name of the action to set for the Area.
+     * @jsptagref.attributedescription The action method to invoke.  The action method must be in the Controller file
+     * of the Page Flow directory.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_action</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The action method to invoke.  The action method must be in the Controller file of the Page Flow directory."
+     * @netui.tldx:attribute reftype="netui-action-url" category="general"
+     */
+    public void setAction(String action)
+            throws JspException
+    {
+        _action = setRequiredValueAttribute(action, "action");
+    }
+
+    /**
+     * Sets the href of the Anchor. This attribute will accept the empty String as a legal value.
+     * @param href - the hyperlink URI for the Area.
+     * @jsptagref.attributedescription The URL to go to.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_href</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The URL to go to."
+     * @netui.tldx:attribute propertyclass="workshop.jspdesigner.properties.URIPropertyClass"
+     * reftype="url"
+     */
+    public void setHref(String href)
+            throws JspException
+    {
+        _href = href;
+    }
+
+    /**
+     * Sets the anchor to be added to the end of the generated hyperlink.
+     * @param location - the name of the location anchor.
+     * @jsptagref.attributedescription Location within the URI to visit.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_location</i>
+     * @netui:attribute required="false"  rtexprvalue="true"
+     * description="Location within the URI to visit."
+     * @netui.tldx:attribute
+     */
+    public void setLocation(String location)
+    {
+        _location = setNonEmptyValueAttribute(location);
+    }
+
+    /**
+     * Set the name of the action for the Anchor.
+     * @param scope - the name of the action to set for the Anchor
+     * @jsptagref.attributedescription The scope
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_scope</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The scope"
+     * @netui.tldx:attribute category="general"
+     */
+    public void setScope(String scope)
+    {
+        _scope = setNonEmptyValueAttribute(scope);
+    }
+
+
+    /**
+     * Sets the formSubmit indicator.
+     * @param formSubmit - whether or not the enclosing Form should be submitted.
+     * @jsptagref.attributedescription Boolean.  If <code>formSubmit</code> is set to true, and the &lt;netui:anchor> tag
+     * is within a &lt;netui:form> tag,
+     * then the form data will be submitted to the method named in the
+     * &lt;netui:form> tag's <code>action</code> attribute.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>boolean_formSubmit</i>
+     * @netui:attribute required="false" rtexprvalue="true" type="boolean"
+     * description="If formSubmit is set to true, and the <netui:anchor> tag
+     * is within a <netui:form> tag,
+     * then the form data will be submitted to the method named in the
+     * <netui:form> tag's action attribute."
+     * @netui.tldx:attribute
+     */
+    public void setFormSubmit(boolean formSubmit)
+    {
+        _formSubmit = formSubmit;
+    }
+
+
+    /**
+     * Sets the tabIndex of the rendered html tag.
+     * @param tabindex - the tab index.
+     * @jsptagref.attributedescription The tabIndex of the rendered HTML tag.  This attribute determines the position of the
+     * rendered HTML tag in the sequence of tags that the user may advance through by pressing the TAB key.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_tabIndex</i>
+     * @netui:attribute required="false"  rtexprvalue="true" type="int"
+     * description="The tabIndex of the rendered HTML tag.  This attribute determines the position of the
+     * rendered HTML tag in the sequence of tags that the user may advance through by pressing the TAB key."
+     * @netui.tldx:attribute category="misc"
+     */
+    public void setTabindex(int tabindex)
+    {
+        _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, TABINDEX, Integer.toString(tabindex));
+    }
+
+
+    /**
+     * Sets the accessKey attribute value.  This should key value of the
+     * keyboard navigation key.  It is recommended not to use the following
+     * values because there are often used by browsers <code>A, C, E, F, G,
+     * H, V, left arrow, and right arrow</code>.
+     * @param accessKey - the accessKey value.
+     * @jsptagref.attributedescription The keyboard navigation key for the element.
+     * The following values are not recommended because they
+     * are often used by browsers: <code>A, C, E, F, G,
+     * H, V, left arrow, and right arrow</code>
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_accessKey</i>
+     * @netui:attribute required="false" rtexprvalue="true"  type="char"
+     * description=" The keyboard navigation key for the element.
+     * The following values are not recommended because they
+     * are often used by browsers: A, C, E, F, G,
+     * H, V, left arrow, and right arrow."
+     * @netui.tldx:attribute category="misc"
+     */
+    public void setAccessKey(char accessKey)
+    {
+        if (accessKey == 0x00)
+            return;
+        _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, ACCESSKEY, Character.toString(accessKey));
+    }
+
+    /**
+     * Sets the onBlur javascript event.
+     * @param onblur - the onBlur event.
+     * @jsptagref.attributedescription The onBlur JavaScript event.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_onBlur</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The onBlur JavaScript event."
+     * @netui.tldx:attribute propertyclass="workshop.jspdesigner.properties.EventPropertyClass" category="event"
+     */
+    public void setOnBlur(String onblur)
+    {
+        _state.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONBLUR, onblur);
+    }
+
+    /**
+     * Sets the onFocus javascript event.
+     * @param onfocus - the onFocus event.
+     * @jsptagref.attributedescription The onFocus JavaScript event.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_onFocus</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The onFocus JavaScript event."
+     * @netui.tldx:attribute propertyclass="workshop.jspdesigner.properties.EventPropertyClass" category="event"
+     */
+    public void setOnFocus(String onfocus)
+    {
+        _state.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONFOCUS, onfocus);
+    }
+
+    //**************************** Helper Routines  *********************************************
+
+    /**
+     * Adds a URL parameter to the generated hyperlink.
+     * @param name  - the name of the parameter to be added.
+     * @param value - the value of the parameter to be added (a String or String[]).
+     */
+    public void addParameter(String name, Object value) throws JspException
+    {
+        if (_params == null) {
+            _params = new HashMap();
+        }
+        ParamHelper.addParam(_params, name, value);
+    }
+
+    /**
+     * This method will create the &lt;a> portion of an anchor.  It is called by subclasses, for example, the
+     * <code>ImageAnchor</code> relies on this code to generate the  &lt;a>.
+     * @param scriptRef a <code>ByRef&lt;String></code> that will contain any JavaScript that may need to be added
+     *               to the generated HTML response.
+     * @return a boolean value indicating if an error occur creating the anchor.
+     * @throws JspException
+     */
+    protected final boolean createAnchorBeginTag(HttpServletRequest request, ByRef scriptRef,
+                                                 TagRenderingBase trb, AbstractRenderAppender writer)
+            throws JspException
+    {
+        int have = 0;
+        String formAction = null;
+        String idScript = null;
+
+        if (_formSubmit)
+            _form = getNearestForm();
+
+        HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
+        ServletContext ctxt = pageContext.getServletContext();
+        JavaScriptUtils jsu = getJavaScriptUtils(request);
+
+        // check the parameters that the user provided
+        if (_href != null) have++;
+        if (_action != null) have++;
+        if (_clientAction != null) have++;
+        if (_linkName != null) have++;
+
+        String tagId = getTagId();
+
+        // if only the _linkName or _tagId is set then we are creating the name attribute only.
+        if (have == 0 && tagId != null) {
+            return createNameAnchor(request, tagId, trb);
+        }
+
+        // if the anchor is submitting a consider this a submit level problem
+        // set the action to the form action.
+        if (_formSubmit == true) {
+            formAction = getFormAction();
+            if ((formAction != null) && (have == 0)) {
+                have++;
+            }
+            if (_action == null)
+                _action = formAction;
+        }
+
+        // if we have not specified a destination or we've specified too many
+        // then we need to report an error.
+        if (have == 0 || have > 1) {
+            String s = Bundle.getString("Tags_Anchor_InvalidAnchorURI", new Object[]{REQUIRED_ATTR});
+            registerTagError(s, null);
+            return false;
+        }
+
+        if (_linkName != null) {
+            return createPageAnchor(request, trb);
+        }
+
+        // report that action is not an action
+        if ((_action != null) && (!PageFlowTagUtils.isAction(request, response, ctxt, _action))) {
+            String s = null;
+            if (_action.equals("")) {
+                s = Bundle.getString("Tags_NullBadAction", null);
+            }
+            else {
+                s = Bundle.getString("Tags_BadAction", _action);
+            }
+            registerTagError(s, null);
+        }
+
+        // we assume that tagId will over have override id if both
+        // are defined.
+        if (tagId != null) {
+            idScript = renderTagId(_state, null, true, false);
+        }
+        else {
+            _state.id = id;
+        }
+
+        // Special case for name anchors
+        if (_clientAction != null) {
+            _state.href = "";
+        }
+        else {
+            // Add the jpfScopeID parameter, if the scope attribute is present.
+            if (_scope != null) {
+                if (_params == null) {
+                    _params = new HashMap();
+                }
+                _params.put(ScopedServletUtils.SCOPE_ID_PARAM, _scope);
+            }
+
+            // Generate the opening anchor element
+            MutableURI uri = null;
+            try {
+                if (_action != null) {
+                    uri = PageFlowTagUtils.rewriteActionURL(pageContext, _action, _params, _location);
+                }
+                else if (_href != null) {
+                    //TODO... OK to use rewrittenResourceURL implying type=RESOURCE for rewriting?
+                    uri = PageFlowTagUtils.rewriteResourceURL(pageContext, _href, _params, _location);
+                }
+            }
+            catch (URISyntaxException e) {
+                // report the error...
+                logger.error(Bundle.getString("Tags_URISyntaxException"));
+                String s = Bundle.getString("Tags_Anchor_URLException",
+                                            new Object[]{e.getMessage()});
+                registerTagError(s, e);
+            }
+
+            if (uri == null) {
+                if (hasErrors()) {
+                    return false;
+                }
+            }
+            else {
+                //TODO... shouldn't this also be a call to response.encodeURL(uri.toString()) for session ID?
+                if (uri.isAbsolute()) {
+                    _state.href = uri.toXMLString();
+                }
+                else {
+                    _state.href = qualifyUrlToContext(uri.toString());
+                }
+            }
+        }
+
+        // We need to combine the onclick features
+        IScriptReporter sr = getScriptReporter();
+        if (sr != null && sr.isRunAtClient()) {
+            if (_clientAction == null) {
+                if (_state.onClick == null) {
+                    _state.onClick = "NetUIAnchorRewriter(this);";
+                }
+                else {
+                    String click = HtmlUtils.escapeEscapes(_state.onClick);
+                    String entry = JavaScriptUtils.getString("createAnchorRewriterOnClickExists",
+                            new Object[]{click});
+                    _state.onClick = entry;
+                }
+            }
+            else {
+                //@todo: we need to support onclick chaining here also...
+                String action = HtmlUtils.escapeEscapes(_clientAction);
+                String entry = JavaScriptUtils.getString("netuiAction",
+                        new Object[]{action});
+                _state.onClick = entry;
+            }
+        }
+
+        // if the user override the onclick we will ignor this
+        if (_state.onClick == null && _formSubmit && formAction != null) {
+            String realFormName = getRealFormName();
+            _state.onClick = jsu.writeAnchorFormSubmitAction(realFormName, _state.href);
+            if (_form != null)
+                _form.generateRealName();
+        }
+
+        if (hasErrors())
+            return false;
+
+        trb.doStartTag(writer, _state);
+
+        //Emit javascript if this anchor needs to sumbit the form
+        if (_formSubmit && formAction != null || idScript != null) {
+            StringBuilder script = new StringBuilder(32);
+            StringBuilderRenderAppender scriptWriter = new StringBuilderRenderAppender(script);
+
+            if (_formSubmit && formAction != null)
+                jsu.writeAnchorFormSubmit(getScriptReporter(),scriptWriter);
+            if (idScript != null)
+                scriptWriter.append(idScript);
+            scriptRef.setRef(script.toString());
+        }
+
+        // create the javaScript
+        return true;
+    }
+
+    /**
+     * @param tagId
+     * @return
+     */
+    private boolean createNameAnchor(ServletRequest req, String tagId, TagRenderingBase trb)
+    {
+        WriteRenderAppender writer = new WriteRenderAppender(pageContext);
+        _state.name = tagId;
+        trb = TagRenderingBase.Factory.getRendering(TagRenderingBase.ANCHOR_TAG, req);
+        trb.doStartTag(writer, _state);
+        return !hasErrors();
+    }
+
+    private boolean createPageAnchor(ServletRequest req, TagRenderingBase trb)
+    {
+        _linkName = _linkName.trim();
+        if (_linkName.charAt(0) != '#') {
+            _state.href = "#" + _linkName;
+        }
+        else
+            _state.href = _linkName;
+
+        WriteRenderAppender writer = new WriteRenderAppender(pageContext);
+        trb = TagRenderingBase.Factory.getRendering(TagRenderingBase.ANCHOR_TAG, req);
+        trb.doStartTag(writer, _state);
+        return !hasErrors();
+    }
+
+    /**
+     * Return the action attribute for the nearest form.
+     * @return The action attribute of the enclosing form
+     */
+    private String getFormAction()
+    {
+        if (_form != null)
+            return _form.getAction();
+        return null;
+    }
+
+    /**
+     * This will get the real name of the form.  This is set in the
+     * id attribute.
+     * @return The String real name of the containing form.
+     */
+    private String getRealFormName()
+    {
+        if (_form != null) {
+            return _form.getRealName();
+        }
+        return null;
+    }
+
+    /**
+     * Release any acquired resources.
+     */
+    protected void localRelease()
+    {
+        super.localRelease();
+
+        _state.clear();
+        _linkName = null;
+        _clientAction = null;
+
+        _action = null;
+        _href = null;
+        _scope = null;
+        _location = null;
+        _params = null;
+        _form = null;
+        _formSubmit = false;
+    }
+
+}

Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/BindingUpdateErrors.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/BindingUpdateErrors.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/BindingUpdateErrors.java&r1=109308&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/BindingUpdateErrors.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/BindingUpdateErrors.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/BindingUpdateErrors.java	Tue Nov 30 23:09:49 2004
@@ -19,8 +19,8 @@
 
 import org.apache.beehive.netui.pageflow.ServerAdapter;
 import org.apache.beehive.netui.pageflow.internal.BindingUpdateError;
-import org.apache.beehive.netui.pageflow.internal.ContextCache;
 import org.apache.beehive.netui.pageflow.internal.InternalUtils;
+import org.apache.beehive.netui.pageflow.internal.ServerAdapterManager;
 import org.apache.beehive.netui.tags.AbstractSimpleTag;
 import org.apache.beehive.netui.util.Bundle;
 
@@ -116,7 +116,7 @@
         }
 
         PageContext pageContext = getPageContext();
-        ServerAdapter sa = ContextCache.get(pageContext.getServletContext()).getServerAdapter();
+        ServerAdapter sa = ServerAdapterManager.getServerAdapter(pageContext.getServletContext());
         ServletRequest request = pageContext.getRequest();
         assert(sa != null);
 

Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Button.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Button.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Button.java&r1=109308&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Button.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Button.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Button.java	Tue Nov 30 23:09:49 2004
@@ -17,10 +17,10 @@
  */
 package org.apache.beehive.netui.tags.html;
 
-import org.apache.beehive.netui.pageflow.util.PageflowTagUtils;
-import org.apache.beehive.netui.pageflow.util.URLRewriterService;
+import org.apache.beehive.netui.core.urls.URLRewriterService;
 import org.apache.beehive.netui.tags.HtmlUtils;
 import org.apache.beehive.netui.tags.IHtmlAccessable;
+import org.apache.beehive.netui.tags.PageFlowTagUtils;
 import org.apache.beehive.netui.tags.rendering.AbstractHtmlState;
 import org.apache.beehive.netui.tags.rendering.InputSubmitTag;
 import org.apache.beehive.netui.tags.rendering.TagRenderingBase;
@@ -229,7 +229,7 @@
         _state.disabled = isDisabled();
 
         if (_action != null) {
-            boolean isAction = PageflowTagUtils.isAction(request, response, pageContext.getServletContext(), _action);
+            boolean isAction = PageFlowTagUtils.isAction(request, response, pageContext.getServletContext(), _action);
             if (isAction) {
                 String overrideAction = ACTION_OVERRIDE + _action;
                 overrideAction = HtmlUtils.addParams(overrideAction, _params, response.getCharacterEncoding());

Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Exceptions.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Exceptions.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Exceptions.java&r1=109308&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Exceptions.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Exceptions.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Exceptions.java	Tue Nov 30 23:09:49 2004
@@ -17,7 +17,7 @@
  */
 package org.apache.beehive.netui.tags.html;
 
-import org.apache.beehive.netui.pageflow.internal.ContextCache;
+import org.apache.beehive.netui.pageflow.internal.ServerAdapterManager;
 import org.apache.beehive.netui.tags.AbstractSimpleTag;
 import org.apache.beehive.netui.util.HtmlExceptionFormatter;
 import org.apache.struts.Globals;
@@ -114,7 +114,7 @@
         }
 
         if (!_showStackTrace && _showDevModeStackTrace) {
-            boolean devMode = !ContextCache.get(pageContext.getServletContext()).getServerAdapter().isInProductionMode();
+            boolean devMode = !ServerAdapterManager.getServerAdapter(pageContext.getServletContext()).isInProductionMode();
             if (devMode)
                 _showStackTrace = true;
         }

Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java&r1=109308&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java&r2=109309
==============================================================================
--- 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	Tue Nov 30 23:09:49 2004
@@ -17,15 +17,17 @@
  */
 package org.apache.beehive.netui.tags.html;
 
+import org.apache.beehive.netui.core.urls.URLRewriterService;
+import org.apache.beehive.netui.core.urls.MutableURI;
 import org.apache.beehive.netui.pageflow.*;
 import org.apache.beehive.netui.pageflow.internal.ContextCache;
 import org.apache.beehive.netui.pageflow.internal.InternalUtils;
-import org.apache.beehive.netui.pageflow.util.PageflowTagUtils;
-import org.apache.beehive.netui.pageflow.util.URLRewriterService;
 import org.apache.beehive.netui.script.common.ImplicitObjectUtil;
 import org.apache.beehive.netui.tags.IHtmlIdWriter;
+import org.apache.beehive.netui.tags.PageFlowTagUtils;
 import org.apache.beehive.netui.tags.rendering.*;
 import org.apache.beehive.netui.util.Bundle;
+import org.apache.beehive.netui.util.logging.Logger;
 import org.apache.beehive.netui.util.ParamHelper;
 import org.apache.struts.Globals;
 import org.apache.struts.action.ActionForm;
@@ -196,6 +198,8 @@
      */
     public final String ID_REQUEST_ATTRIBUTE = "netuiIdGenerator";
 
+    private static final Logger logger = Logger.getInstance(Form.class);
+
     // unique name of the form
     private static String FORM_ID = "Netui_Form_";
 
@@ -290,7 +294,6 @@
             throws JspException
     {
         _state.action = setRequiredValueAttribute(action, "action");
-        ;
     }
 
     /**
@@ -712,31 +715,31 @@
             _state.method = FORM_POST;
 
         // encode the action
-        String actionUrl = PageflowTagUtils.getRewrittenFormAction(request, _state.action, pageContext);
+        MutableURI actionUrl = null;
+        try {
+            actionUrl = PageFlowTagUtils.rewriteActionURL(pageContext, _state.action, null, _location);
+        }
+        catch ( java.net.URISyntaxException e ) {
+            // report the error...
+            logger.error(Bundle.getString("Tags_URISyntaxException"));
+            String s = Bundle.getString("Tags_Form_URLException",
+                                        new Object[]{_state.action, e.getMessage()});
+            registerTagError(s, e);
+        }
 
         // If the rewritten form action contains request parameters, turn them into hidden fields --
         // it's not legal to include them in the action URI on a GET.
-        int query = actionUrl.indexOf('?');
         Map extraHiddenParams = null;
-        if (query != -1 && _state.method != null && _state.method.equalsIgnoreCase(FORM_GET)
+        if (actionUrl != null && _state.method != null && _state.method.equalsIgnoreCase(FORM_GET)
                 && !URLRewriterService.allowParamsOnFormAction(pageContext.getServletContext(), request)) {
-            extraHiddenParams = new LinkedHashMap();
-            StringTokenizer tok = new StringTokenizer(actionUrl.substring(query + 1), "&");
-            while (tok.hasMoreTokens()) {
-                String keyVal = tok.nextToken();
-                int eq = keyVal.indexOf('=');
-                if (eq != -1) {
-                    extraHiddenParams.put(keyVal.substring(0, eq), keyVal.substring(eq + 1));
-                }
-                else {
-                    extraHiddenParams.put(keyVal, "");
-                }
-            }
-
-            actionUrl = actionUrl.substring(0, query);
+            extraHiddenParams = actionUrl.getParameters();
+            actionUrl.setQuery(null);
         }
 
-        _state.action = actionUrl;
+        HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
+        if (actionUrl != null) {
+            _state.action = response.encodeURL( actionUrl.toString() );
+        }
 
         WriteRenderAppender writer = new WriteRenderAppender(pageContext);
         TagRenderingBase br = TagRenderingBase.Factory.getRendering(TagRenderingBase.FORM_TAG, request);
@@ -774,9 +777,14 @@
 
         // add the extra hidden parameters
         if (extraHiddenParams != null) {
-            for (Iterator i = extraHiddenParams.entrySet().iterator(); i.hasNext();) {
-                Map.Entry entry = (Map.Entry) i.next();
-                writeHiddenParam((String) entry.getKey(), (String) entry.getValue(), writer, request,true);
+            Iterator names = extraHiddenParams.keySet().iterator();
+            while (names.hasNext()) {
+                String name = (String) names.next();
+                List valueList = (List) extraHiddenParams.get(name);
+                Iterator values = valueList.iterator();
+                while (values.hasNext()) {
+                    writeHiddenParam(name, (String) values.next(), writer, request, true);
+                }
             }
         }
 
@@ -901,7 +909,7 @@
         _flowController = PageFlowUtils.getCurrentPageFlow(request);
 
         // check to see if this is a bad action
-        boolean isAction = PageflowTagUtils.isAction(request, response, servletContext, _state.action);
+        boolean isAction = PageFlowTagUtils.isAction(request, response, servletContext, _state.action);
         if (!isAction) {
             registerTagError(Bundle.getString("Tags_BadAction", _state.action), null);
             return;

Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Image.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Image.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Image.java&r1=109308&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Image.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Image.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Image.java	Tue Nov 30 23:09:49 2004
@@ -17,8 +17,8 @@
  */
 package org.apache.beehive.netui.tags.html;
 
-import org.apache.beehive.netui.pageflow.util.PageflowTagUtils;
-import org.apache.beehive.netui.tags.HtmlUtils;
+import org.apache.beehive.netui.core.urls.MutableURI;
+import org.apache.beehive.netui.tags.PageFlowTagUtils;
 import org.apache.beehive.netui.tags.rendering.AbstractHtmlState;
 import org.apache.beehive.netui.tags.rendering.ImageTag;
 import org.apache.beehive.netui.tags.rendering.TagRenderingBase;
@@ -27,9 +27,9 @@
 import org.apache.beehive.netui.util.ParamHelper;
 
 import javax.servlet.ServletRequest;
-import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.jsp.JspException;
+import java.net.URISyntaxException;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -302,14 +302,21 @@
 
         // Generate the name definition or image element
 
-        // the src attribute
-        String srcurl = url(_state.src);
-        if (srcurl != null) {
-            srcurl = PageflowTagUtils.prepareResourceUrl(pageContext, srcurl);
-            if (_location != null) {
-                srcurl = srcurl + "#" + _location;
+        MutableURI uri = null;
+        if (_state.src != null) {
+            try {
+                uri = PageFlowTagUtils.rewriteResourceURL(pageContext, _state.src, _params, _location);
             }
-            _state.src = srcurl;
+            catch (URISyntaxException e) {
+                // report the error...
+                String s = Bundle.getString("Tags_Image_URLException",
+                                            new Object[]{_state.src, e.getMessage()});
+                registerTagError(s, e);
+            }
+        }
+
+        if (uri != null) {
+            _state.src = ((HttpServletResponse) pageContext.getResponse()).encodeURL(uri.toString());
         }
 
         // we assume that tagId will over have override id if both
@@ -351,32 +358,5 @@
         _location = null;
         _id = null;
         _params = null;
-    }
-
-    /**
-     * Return the specified src URL, modified as necessary with optional
-     * request parameters.
-     * @param url The URL to be modified (or null if this url will not be used)
-     * @throws JspException if an error occurs preparing the URL
-     */
-    protected String url(String url)
-            throws JspException
-    {
-
-        if (url == null || _params == null)
-            return url;
-
-        HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
-        HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
-        String encoding = response.getCharacterEncoding();
-
-        StringBuilder src = new StringBuilder(128);
-        if (url.startsWith("/")) {
-            src.append(req.getContextPath());
-        }
-
-        url = HtmlUtils.addParams(url, _params, encoding);
-        src.append(url);
-        return src.toString();
     }
 }

Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageAnchor.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageAnchor.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageAnchor.java&r1=109308&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageAnchor.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageAnchor.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageAnchor.java	Tue Nov 30 23:09:49 2004
@@ -17,12 +17,14 @@
  */
 package org.apache.beehive.netui.tags.html;
 
-import org.apache.beehive.netui.pageflow.util.PageflowTagUtils;
+import org.apache.beehive.netui.core.urls.MutableURI;
 import org.apache.beehive.netui.tags.IHtmlAccessable;
 import org.apache.beehive.netui.tags.ByRef;
+import org.apache.beehive.netui.tags.PageFlowTagUtils;
 import org.apache.beehive.netui.tags.rendering.*;
 import org.apache.beehive.netui.util.Bundle;
 
+import java.net.URISyntaxException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.jsp.JspException;
@@ -424,16 +426,33 @@
 
         // set the source and lowsrc attributes
         // the lowsrc is deprecated and should be removed.
+        HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
         if (_imgState.src != null) {
-            _imgState.src = PageflowTagUtils.prepareResourceUrl(pageContext, _imgState.src);
+            try {
+                MutableURI uri = PageFlowTagUtils.rewriteResourceURL(pageContext, _imgState.src, null, null);
+                _imgState.src = response.encodeURL(uri.toString());
+            }
+            catch (URISyntaxException e) {
+                // report the error...
+                String s = Bundle.getString("Tags_Image_URLException",
+                                            new Object[]{_imgState.src, e.getMessage()});
+                registerTagError(s, e);
+            }
         }
 
         // set the rollover image
         if (_rolloverImage != null) {
-            _rolloverImage = PageflowTagUtils.prepareResourceUrl(pageContext, _rolloverImage);
-            _rolloverImage = qualifyUrlToContext(_rolloverImage);
+            try {
+                MutableURI uri = PageFlowTagUtils.rewriteResourceURL(pageContext, _rolloverImage, null, null);
+                _rolloverImage = response.encodeURL(qualifyUrlToContext(uri.toString()));
+            }
+            catch (URISyntaxException e) {
+                // report the error...
+                String s = Bundle.getString("Tags_Rollover_Image_URLException",
+                                            new Object[]{_rolloverImage, e.getMessage()});
+                registerTagError(s, e);
+            }
 
-            HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
             if (getJavaScriptAttribute(ONMOUSEOUT) == null) {
                 _imgState.onmouseout = "swapImage(this,'" + response.encodeURL(_imgState.src) + "')";
             }

Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageButton.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageButton.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageButton.java&r1=109308&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageButton.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageButton.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageButton.java	Tue Nov 30 23:09:49 2004
@@ -17,8 +17,9 @@
  */
 package org.apache.beehive.netui.tags.html;
 
-import org.apache.beehive.netui.pageflow.util.PageflowTagUtils;
+import org.apache.beehive.netui.core.urls.MutableURI;
 import org.apache.beehive.netui.tags.IHtmlAccessable;
+import org.apache.beehive.netui.tags.PageFlowTagUtils;
 import org.apache.beehive.netui.tags.rendering.AbstractHtmlState;
 import org.apache.beehive.netui.tags.rendering.InputImageTag;
 import org.apache.beehive.netui.tags.rendering.TagRenderingBase;
@@ -27,8 +28,10 @@
 import org.apache.struts.Globals;
 import org.apache.struts.config.ModuleConfig;
 
+import java.net.URISyntaxException;
 import javax.servlet.ServletRequest;
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import javax.servlet.jsp.JspException;
 
 /**
@@ -300,10 +303,19 @@
             _state.id = _id;
         }
 
+        HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
         tmp = src();
         if (tmp != null) {
-            tmp = PageflowTagUtils.prepareResourceUrl(pageContext, tmp);
-            _state.src = tmp;
+            try {
+                MutableURI uri = PageFlowTagUtils.rewriteResourceURL(pageContext, tmp, null, null);
+                _state.src = response.encodeURL(uri.toString());
+            }
+            catch (URISyntaxException e) {
+                // report the error...
+                String s = Bundle.getString("Tags_Image_URLException",
+                                            new Object[]{_state.src, e.getMessage()});
+                registerTagError(s, e);
+            }
         }
 
         _state.disabled = isDisabled();
@@ -316,12 +328,20 @@
                 return EVAL_PAGE;
             }
 
-            _rolloverImage = PageflowTagUtils.prepareResourceUrl(pageContext, _rolloverImage);
-            _rolloverImage = qualifyUrlToContext(_rolloverImage);
+            try {
+                MutableURI uri = PageFlowTagUtils.rewriteResourceURL(pageContext, _rolloverImage, null, null);
+                _rolloverImage = response.encodeURL(qualifyUrlToContext(uri.toString()));
+            }
+            catch (URISyntaxException e) {
+                // report the error...
+                String s = Bundle.getString("Tags_Rollover_Image_URLException",
+                                            new Object[]{_rolloverImage, e.getMessage()});
+                registerTagError(s, e);
+            }
         }
 
         if ((getJavaScriptAttribute(ONMOUSEOUT) == null) && (_rolloverImage != null)) {
-            setOnMouseOut("swapImage(this,'" + tmp + "')");
+            setOnMouseOut("swapImage(this,'" + _state.src + "')");
         }
         if ((getJavaScriptAttribute(ONMOUSEOVER) == null) && (_rolloverImage != null)) {
             setOnMouseOver("swapImage(this,'" + _rolloverImage + "')");

Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RewriteURL.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RewriteURL.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RewriteURL.java&r1=109308&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RewriteURL.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RewriteURL.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RewriteURL.java	Tue Nov 30 23:09:49 2004
@@ -17,11 +17,14 @@
  */
 package org.apache.beehive.netui.tags.html;
 
-import org.apache.beehive.netui.pageflow.util.URLRewriter;
-import org.apache.beehive.netui.pageflow.util.URLRewriterService;
+import org.apache.beehive.netui.core.urls.MutableURI;
+import org.apache.beehive.netui.core.urls.URLRewriter;
+import org.apache.beehive.netui.core.urls.URLRewriterService;
 import org.apache.beehive.netui.tags.AbstractClassicTag;
-import org.apache.beehive.netui.util.FileUtils;
+import org.apache.beehive.netui.tags.PageFlowTagUtils;
+import org.apache.beehive.netui.util.Bundle;
 
+import java.net.URISyntaxException;
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -85,20 +88,25 @@
         HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
         ServletContext context = pageContext.getServletContext();
 
-        String type = URLRewriter.ACTION_UNSECURE;
-        boolean absoluteUrl = false;
+        MutableURI uri = null;
+        try {
+            boolean needsToBeSecure = false;
+            uri = new MutableURI(url);
+            if (!uri.isAbsolute() && PageFlowTagUtils.needsSecure(context, request, url, true)) {
+                needsToBeSecure = true;
+            }
+
+            URLRewriterService.rewriteURL(context, request, response, uri, URLRewriter.Type.ACTION, needsToBeSecure);
+            //TODO... why no call to response.encodeURL(uri.toString()) for session ID?
+            write(uri.toString());
+        }
+        catch (URISyntaxException e) {
+            // report the error...
+            String s = Bundle.getString("Tags_RewriteURL_URLException",
+                                        new Object[]{url, e.getMessage()});
+            registerTagError(s, e);
+        }
 
-        if (FileUtils.isAbsoluteURI(url))
-            absoluteUrl = true;
-
-        if ((!absoluteUrl) && (URLRewriterService.needsSecure(request,
-                context, url, true)))
-            type = URLRewriter.ACTION_SECURE;
-
-        String internalHref = URLRewriterService.rewriteURL(context, request, response,
-                url, type);
-
-        write(internalHref);
         localRelease();
         return SKIP_BODY;
     }

Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java&r1=109308&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java	Tue Nov 30 23:09:49 2004
@@ -17,10 +17,10 @@
  */
 package org.apache.beehive.netui.tags.tree;
 
+import org.apache.beehive.netui.core.urls.MutableURI;
 import org.apache.beehive.netui.pageflow.internal.InternalUtils;
-import org.apache.beehive.netui.pageflow.internal.ContextCache;
+import org.apache.beehive.netui.pageflow.internal.ServerAdapterManager;
 import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
-import org.apache.beehive.netui.pageflow.util.PageflowTagUtils;
 import org.apache.beehive.netui.script.ExpressionUpdateException;
 import org.apache.beehive.netui.script.IllegalExpressionException;
 import org.apache.beehive.netui.tags.*;
@@ -28,7 +28,6 @@
 import org.apache.beehive.netui.tags.html.JavaScriptUtils;
 import org.apache.beehive.netui.tags.rendering.*;
 import org.apache.beehive.netui.util.Bundle;
-import org.apache.beehive.netui.util.FileUtils;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -36,7 +35,9 @@
 import javax.servlet.jsp.PageContext;
 import javax.servlet.ServletContext;
 import java.io.IOException;
+import java.net.URISyntaxException;
 import java.net.URLEncoder;
+import java.util.HashMap;
 
 
 /**
@@ -734,7 +735,7 @@
         // In devMode we will verify the structure of the tree.  This will not run in
         // production mode.
         ServletContext servletContext = InternalUtils.getServletContext(request);
-        boolean devMode = !ContextCache.get(servletContext).getServerAdapter().isInProductionMode();
+        boolean devMode = !ServerAdapterManager.getServerAdapter(servletContext).isInProductionMode();
         if (devMode) {
             boolean error = false;
             StringBuilder errorText = new StringBuilder(64);
@@ -793,7 +794,7 @@
         // boolean flag that will indicate if there is an open anchor created
         boolean closeAnchor = false;
         if (!_runAtClient)
-            closeAnchor = renderExpansionAnchor(sb, anchorRenderer, request, response, node, encodedNodeName);
+            closeAnchor = renderExpansionAnchor(sb, anchorRenderer, request, response, node, nodeName);
         else {
             // Render client expansion and initialize the tree JavaScript support
             closeAnchor = renderClientExpansionAnchor(sb, anchorRenderer, node, encodedNodeName);
@@ -860,20 +861,32 @@
             // process the action into a URL
             PageContext pageContext = getPageContext();
             if (action != null && selectionLink == null) {
-                String qualifiedAction = PageflowTagUtils.qualifiedAction(pageContext.getServletContext(),action);
-                selectionLink = PageflowTagUtils.createActionURL(request, qualifiedAction);
-                selectionLink = PageflowTagUtils.addParam(selectionLink, TreeElement.SELECTED_NODE, encodedNodeName);
-                if (_tagId != null)
-                    selectionLink = PageflowTagUtils.addParam(selectionLink, TreeElement.TREE_ID, _tagId);
+                HashMap params = new HashMap();
+                params.put(TreeElement.SELECTED_NODE, nodeName);
+                if (_tagId != null) {
+                    params.put(TreeElement.TREE_ID, _tagId);
+                }
 
                 // Add the jpf ScopeID param if necessary.
                 String scope = node.getScope();
                 if (scope != null) {
-                    selectionLink = PageflowTagUtils.addParam(selectionLink, ScopedServletUtils.SCOPE_ID_PARAM, scope);
+                    params.put(ScopedServletUtils.SCOPE_ID_PARAM, scope);
+                }
+
+                MutableURI uri = null;
+                try {
+                    uri = PageFlowTagUtils.rewriteActionURL(pageContext, action, params, null);
+                }
+                catch (URISyntaxException e) {
+                    // report the error...
+                    String s = Bundle.getString("Tags_Tree_Node_URLException",
+                                                new Object[]{action, e.getMessage()});
+                    registerTagError(s, e);
                 }
 
-                if ((selectionLink != null) && (!FileUtils.isAbsoluteURI(selectionLink)))
-                    selectionLink = PageflowTagUtils.prepareActionUrl(pageContext, selectionLink);
+                if (uri != null) {
+                    selectionLink = response.encodeURL(uri.toString());
+                }
             }
         }
 
@@ -988,7 +1001,7 @@
 
     private boolean renderExpansionAnchor(StringBuilder sb, TagRenderingBase anchorRenderer,
                                           HttpServletRequest request, HttpServletResponse response,
-                                          TreeElement node, String encodedNodeName)
+                                          TreeElement node, String nodeName)
             throws JspException
     {
         // Render the tree state image for this node
@@ -997,31 +1010,32 @@
         if (action == null) {
             action = _iState.getSelectionAction();
         }
-        boolean isAction = PageflowTagUtils.isAction(request, response, pageContext.getServletContext(), action);
+        boolean isAction = PageFlowTagUtils.isAction(request, response, pageContext.getServletContext(), action);
         if (!isAction) {
             registerTagError(Bundle.getString("Tags_BadAction", action), null);
             return false;
         }
-        String qualifiedAction = PageflowTagUtils.qualifiedAction(pageContext.getServletContext(),action);
-        action = PageflowTagUtils.createActionURL(request, qualifiedAction);
-        action = PageflowTagUtils.prepareActionUrl(pageContext, action);
 
         // encode the tree parameters into the action.
-        String amp = TagRenderingBase.getAmp(request);
-        if (action.indexOf("?") > -1) {
-            action = action + amp + TreeElement.EXPAND_NODE + "=" + encodedNodeName;
+        HashMap params = new HashMap();
+        params.put(TreeElement.EXPAND_NODE, nodeName);
+        assert (_tagId != null);
+        params.put(TreeElement.TREE_ID, _tagId);
+        MutableURI uri = null;
+        try {
+            uri = PageFlowTagUtils.rewriteActionURL(pageContext, action, params, null);
         }
-        else {
-            action = action + "?" + TreeElement.EXPAND_NODE + "=" + encodedNodeName;
+        catch (URISyntaxException e) {
+            // report the error...
+            String s = Bundle.getString("Tags_Tree_Node_URLException",
+                                        new Object[]{action, e.getMessage()});
+            registerTagError(s, e);
         }
-        assert (_tagId != null);
-        action = action + amp + TreeElement.TREE_ID + "=" + _tagId;
-
 
         boolean ret = false;
-        if ((action != null) && !node.isLeaf()) {
+        if ((uri != null) && !node.isLeaf()) {
             _anchorState.clear();
-            _anchorState.href = action;
+            _anchorState.href = response.encodeURL(uri.toString());
             _anchorState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, TARGET, _iState.getExpandTarget());
             sb.append("      ");
             StringBuilderRenderAppender writer = new StringBuilderRenderAppender(sb);

Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/TreeItem.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/TreeItem.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/TreeItem.java&r1=109308&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/TreeItem.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/TreeItem.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/TreeItem.java	Tue Nov 30 23:09:49 2004
@@ -17,8 +17,8 @@
  */
 package org.apache.beehive.netui.tags.tree;
 
-import org.apache.beehive.netui.pageflow.util.PageflowTagUtils;
 import org.apache.beehive.netui.tags.AbstractSimpleTag;
+import org.apache.beehive.netui.tags.PageFlowTagUtils;
 import org.apache.beehive.netui.util.Bundle;
 
 import javax.servlet.http.HttpServletRequest;
@@ -302,7 +302,7 @@
         if (_action != null) {
             HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
             HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
-            boolean isAction = PageflowTagUtils.isAction(request, response, pageContext.getServletContext(), _action);
+            boolean isAction = PageFlowTagUtils.isAction(request, response, pageContext.getServletContext(), _action);
             if (!isAction) {
                 registerTagError(Bundle.getString("Tags_BadAction", _action), null);
             }

Modified: incubator/beehive/trunk/netui/src/util/build.xml
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/build.xml?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/util/build.xml&r1=109308&p2=incubator/beehive/trunk/netui/src/util/build.xml&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/util/build.xml	(original)
+++ incubator/beehive/trunk/netui/src/util/build.xml	Tue Nov 30 23:09:49 2004
@@ -18,6 +18,7 @@
         <pathelement path="${commons-logging.jar}"/>
         <pathelement path="${xbean.jar}"/>
         <pathelement path="${jsr173.jar}"/>
+        <pathelement path="${scoping.jar}"/>
     </path>
 
     <target name="build">

Modified: incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/cache/ServletContextCache.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/cache/ServletContextCache.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/cache/ServletContextCache.java&r1=109308&p2=incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/cache/ServletContextCache.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/cache/ServletContextCache.java	(original)
+++ incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/cache/ServletContextCache.java	Tue Nov 30 23:09:49 2004
@@ -1,42 +0,0 @@
-/*
- * 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.util.cache;
-
-import javax.servlet.ServletContext;
-
-public abstract class ServletContextCache
-{
-    protected void initInternal( ServletContext servletContext )
-    {
-        servletContext.setAttribute( getKey(), this );
-    }
-    
-    protected static ServletContextCache get( ServletContext servletContext, String key )
-    {
-        ServletContextCache cache = ( ServletContextCache ) servletContext.getAttribute( key );
-        
-        if ( cache == null )
-        {
-            throw new IllegalStateException( "Cache " + key + " was not initialized in the ServletContext." );
-        }
-        
-        return cache;
-    }
-    
-    protected abstract String getKey();
-}

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=109309&p1=incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties&r1=109308&p2=incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties&r2=109309
==============================================================================
--- 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	Tue Nov 30 23:09:49 2004
@@ -56,7 +56,7 @@
 Tags_FormattableParentRequired=Format tags require a parent that is Formattable.
 Tags_EmptyStringFormatException=The value to be formatted by the FormatNumber cannot be an empty string or null.
 Tags_BadParameterType=Parameter {0} cannot be a Map.
-Tags_MalformedURLException=MalformedURLException occured.
+Tags_URISyntaxException=URISyntaxException occured.
 Tags_ExpressionEvaluationFailure=Expression evaluation failed for ''{0}''.
 Tags_IsExpressionFailure=The string ''{0}'' is not an expression : {1}
 Tags_ExpressionEvaluationException=Caught exception evaluating expression ''{0}'': {1}.
@@ -92,6 +92,10 @@
 Tags_Anchor_ForwardError=URL Exception: {0}.  This may be caused because an ActionMapping cannot be found (the page was not accessed through an Action).
 Tags_Form_URLException=The action ''{0}'' for the Form is malformed: {1}
 Tags_Anchor_InvalidAnchorURI=The Anchor URI is invalid; it must be exactly one of {0}
+Tags_Image_URLException=The src ''{0}'' for the Image is malformed: {1}
+Tags_Rollover_Image_URLException=The src ''{0}'' for the rollover Image is malformed: {1}
+Tags_RewriteURL_URLException=The url ''{0}'' for the RewriteURL is malformed: {1}
+Tags_Tree_Node_URLException=The action ''{0}'' for the tree node is malformed: {1}
 Tags_HRefEvalNull=The href expression "{0}" resolved to null.
 Tags_formatDate_Type_Error=The type "{0}" may not be formatted by a formatDate tag.
 Tags_LocaleRequiresLanguage=If you set a country, you must also set a language when specifying a local, defaulting to Locale of Request.  The country set was "{0}"

Modified: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/mockportal/MockPortalUrlRewriter.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/mockportal/MockPortalUrlRewriter.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/mockportal/MockPortalUrlRewriter.java&r1=109308&p2=incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/mockportal/MockPortalUrlRewriter.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/mockportal/MockPortalUrlRewriter.java	(original)
+++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/mockportal/MockPortalUrlRewriter.java	Tue Nov 30 23:09:49 2004
@@ -22,7 +22,6 @@
 import org.apache.beehive.netui.pageflow.util.URLRewriterService;
 import org.apache.beehive.netui.pageflow.PageFlowConstants;
 
-import javax.servlet.jsp.PageContext;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;

Modified: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/mockportal/MockPortletTag.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/mockportal/MockPortletTag.java?view=diff&rev=109309&p1=incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/mockportal/MockPortletTag.java&r1=109308&p2=incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/mockportal/MockPortletTag.java&r2=109309
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/mockportal/MockPortletTag.java	(original)
+++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/src/mockportal/MockPortletTag.java	Tue Nov 30 23:09:49 2004
@@ -108,8 +108,6 @@
             
             boolean submittedThisPortlet = ( scopedRequest.getParameter( "_submit" ) != null );
 
-            String uri = ( currentURL != null ? currentURL : _pageFlowURI );
-            
             if ( currentURL == null )   // First time -- execute the begin action
             {
                 if ( actionResolver != null )
@@ -255,7 +253,8 @@
     {
         HttpServletRequest outerRequest = ( HttpServletRequest ) pageContext.getRequest();        
         ScopedRequest scopedRequest = 
-                ScopedServletUtils.getScopedRequest( outerRequest, null, pageContext.getServletContext(), _portletID, true );
+                ScopedServletUtils.getScopedRequest( outerRequest, null, pageContext.getServletContext(),
+                                                     _portletID, true );
         scopedRequest.persistAttributes();
         
         pageContext.removeAttribute( "mockCurrentUrl" );