Author: rich
Date: Fri Mar 4 20:02:06 2005
New Revision: 156226
URL: http://svn.apache.org/viewcvs?view=rev&rev=156226
Log:
Fix for http://issues.apache.org/jira/browse/BEEHIVE-405 : JSF page failing
with Assertion error
tests: netui bvt, drt.myfaces, drt.jsf-ri (WinXP)
BB: self (linux)
Modified:
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/EmptyNestingStackException.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/PageFlowPageFilter.java
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowViewHandler.java
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/PageFlowRequestWrapper.java
Modified:
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/EmptyNestingStackException.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/EmptyNestingStackException.java?view=diff&r1=156225&r2=156226
==============================================================================
---
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/EmptyNestingStackException.java
(original)
+++
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/EmptyNestingStackException.java
Fri Mar 4 20:02:06 2005
@@ -19,9 +19,9 @@
/**
- * Exception that occurs when the user invokes an action in a nested page flow
that is qualified
- * with a <code>@jpf:forward
return-action="</code><i>action-name-in-calling-pageflow</i>
- * <code>"</code> annotation, but there is no calling page flow. This can
happen in iterative
+ * Exception that occurs when the user invokes an action in a nested page flow
that uses a
+ * <code>@[EMAIL PROTECTED] org.apache.beehive.netui.pageflow.annotations.Jpf
Jpf}.Forward(returnAction="</code><i>action-name-in-calling-pageflow</i><code>")</code>
+ * annotation, but there is no calling page flow. This can happen in iterative
* development mode when you have modified files and caused the web
application to be redeployed,
* or when the session expires.
*/
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&r1=156225&r2=156226
==============================================================================
---
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
Fri Mar 4 20:02:06 2005
@@ -47,10 +47,12 @@
/**
* An object of this type is returned from an action methods in a [EMAIL
PROTECTED] PageFlowController} to
* determine the next URI to be displayed. It is constructed on the name of a
forward defined
- * by the <code>@jpf:forward</code> tag, and resolves to the URI specified in
that forward.
+ * by the @[EMAIL PROTECTED] Jpf.Forward} annotation, and resolves to the URI
specified in that forward.
*/
public class Forward extends ActionForward
{
+ private static final ActionForm[] EMPTY_ACTION_FORM_ARRAY = new
ActionForm[0];
+
public static final int RETURN_TO_NONE = 0;
public static final int RETURN_TO_CURRENT_PAGE = 1;
public static final int RETURN_TO_PREVIOUS_PAGE = 2;
@@ -89,7 +91,6 @@
}
private List _outputForms;
- private String _path;
private boolean _isNestedReturn = false;
private boolean _init = false;
@@ -147,11 +148,11 @@
}
/**
- * Constructor which accepts the name of a forward defined by the
<code>@jpf:forward</code>
- * tag. The values returned from [EMAIL PROTECTED] #getPath}, [EMAIL
PROTECTED] #getRedirect} and
+ * Constructor which accepts the name of a forward defined by the
<code>@[EMAIL PROTECTED] Jpf.Forward}</code>
+ * annotation. The values returned from [EMAIL PROTECTED] #getPath},
[EMAIL PROTECTED] #getRedirect} and
* [EMAIL PROTECTED] #contextRelative} are resolved from this forward.
*
- * @param forwardName the name of the forward (<code>@jpf:forward</code>)
to resolve.
+ * @param forwardName the name of the forward (<code>@[EMAIL PROTECTED]
Jpf.Forward}</code>) to resolve.
*/
public Forward( String forwardName )
{
@@ -159,12 +160,12 @@
}
/**
- * Constructor which accepts the name of a forward defined by the
<code>@jpf:forward</code>
- * tag. The values returned from [EMAIL PROTECTED] #getPath}, [EMAIL
PROTECTED] #getRedirect} and
+ * Constructor which accepts the name of a forward defined by the
<code>@[EMAIL PROTECTED] Jpf.Forward}</code>
+ * annotation. The values returned from [EMAIL PROTECTED] #getPath},
[EMAIL PROTECTED] #getRedirect} and
* [EMAIL PROTECTED] #contextRelative} are resolved from this forward.
Also accepts a form bean
* to make available in the request (or user session, as appropriate).
*
- * @param forwardName the name of the forward (<code>@jpf:forward</code>)
to resolve.
+ * @param forwardName the name of the forward (<code>@[EMAIL PROTECTED]
Jpf.Forward}</code>) to resolve.
* @param outputFormBean a form bean instance to make available in the
request (or user session, as appropriate).
* See [EMAIL PROTECTED] #addOutputForm} for details about how
this manifests itself.
*/
@@ -179,12 +180,12 @@
}
/**
- * Constructor which accepts the name of a forward defined by the
<code>@jpf:forward</code>
- * tag. The values returned from [EMAIL PROTECTED] #getPath}, [EMAIL
PROTECTED] #getRedirect} and
+ * Constructor which accepts the name of a forward defined by the
<code>@[EMAIL PROTECTED] Jpf.Forward}</code>
+ * annotation. The values returned from [EMAIL PROTECTED] #getPath},
[EMAIL PROTECTED] #getRedirect} and
* [EMAIL PROTECTED] #contextRelative} are resolved from this forward.
Also accepts a named action output
* to make available in the request, through [EMAIL PROTECTED]
PageFlowUtils#getActionOutput}..
*
- * @param forwardName the name of the forward (<code>@jpf:forward</code>)
to resolve.
+ * @param forwardName the name of the forward (<code>@[EMAIL PROTECTED]
Jpf.Forward}</code>) to resolve.
* @param actionOutputName the name of a action output to make available
in the request.
* @param actionOutputValue the action output object to make available in
the request.
*/
@@ -199,33 +200,33 @@
* the Forward will cause server forward (not a browser redirect); to
change this, use
* [EMAIL PROTECTED] #setRedirect}.
*
- * @param path the URI to return for [EMAIL PROTECTED] #getPath}.
+ * @param uri the URI to return for [EMAIL PROTECTED] #getPath}.
*/
- public Forward( URI path )
+ public Forward( URI uri )
{
- setPath( path.toString() );
- setContextRelative( path.getPath().startsWith( "/" ) );
- if ( path.isAbsolute() ) super.setRedirect( true );
+ setPath( uri.toString() );
+ setContextRelative( uri.getPath().startsWith( "/" ) );
+ if ( uri.isAbsolute() ) super.setRedirect( true );
_explicitPath = true;
}
/**
* Constructs a Forward that returns the given URI for [EMAIL PROTECTED]
#getPath}.
*
- * @param path the URI to return for [EMAIL PROTECTED] #getPath}.
- * @param redirect set to <code>true</code> if this Forward should cause a
browser redirect;
+ * @param uri the URI to return for [EMAIL PROTECTED] #getPath}.
+ * @param doRedirect set to <code>true</code> if this Forward should cause
a browser redirect;
* <code>false</code> if it should cause a server forward.
*/
- public Forward( URI path, boolean redirect )
+ public Forward( URI uri, boolean doRedirect )
{
- if ( ! redirect && path.isAbsolute() )
+ if ( ! doRedirect && uri.isAbsolute() )
{
throw new IllegalStateException( "Redirect value cannot be set to
false for an absolute URI." );
}
- setPath( path.toString() );
- setRedirect( redirect );
- setContextRelative( path.getPath().startsWith( "/" ) );
+ setPath( uri.toString() );
+ setRedirect( doRedirect );
+ setContextRelative( uri.getPath().startsWith( "/" ) );
_explicitPath = true;
}
@@ -233,11 +234,11 @@
* Constructs a Forward that returns the given URL for [EMAIL PROTECTED]
#getPath}. Because the URL path
* is absolute by nature, this Forward will cause a browser redirect.
*
- * @param path the URL to return for [EMAIL PROTECTED] #getPath}.
+ * @param url the URL to return for [EMAIL PROTECTED] #getPath}.
*/
- public Forward( URL path )
+ public Forward( URL url )
{
- setPath( path.toString() );
+ setPath( url.toString() );
super.setRedirect( true );
_explicitPath = true;
}
@@ -256,13 +257,13 @@
/**
* Set whether the URI resolved by this Forward should be redirected to.
*
- * @param redirect if <code>true</code>, the controller will send a
browser redirect to
+ * @param doRedirect if <code>true</code>, the controller will send a
browser redirect to
* the URI for this Forward; otherwise, it will do a
server forward to
* the URI.
*/
- public void setRedirect( boolean redirect )
+ public void setRedirect( boolean doRedirect )
{
- super.setRedirect( redirect );
+ super.setRedirect( doRedirect );
_redirectSetThroughMethod = true;
}
@@ -289,15 +290,8 @@
{
assert formBean != null : "The output form bean may not me null.";
- if ( formBean == null )
- {
- throw new IllegalArgumentException( "The output form bean may not
be null." );
- }
-
- if ( _outputForms == null )
- {
- _outputForms = new ArrayList();
- }
+ if ( formBean == null ) throw new IllegalArgumentException( "The
output form bean may not be null." );
+ if ( _outputForms == null ) _outputForms = new ArrayList();
//
// Throw an exception if this is a redirect, and if there was an
output form added. Output forms are carried
@@ -322,8 +316,8 @@
*/
public final ActionForm[] getOutputForms()
{
- if ( _outputForms == null ) return new ActionForm[0];
- return ( ActionForm[] ) _outputForms.toArray( new ActionForm[0] );
+ if ( _outputForms == null ) return EMPTY_ACTION_FORM_ARRAY;
+ return ( ActionForm[] ) _outputForms.toArray( EMPTY_ACTION_FORM_ARRAY
);
}
/**
@@ -368,9 +362,9 @@
* conditions is met:
* <ul>
* <li>the name around which this object was constructed resolves
to a path defined
- * by a <code>@jpf:forward</code>, or</li>
+ * by a <code>@[EMAIL PROTECTED] Jpf.Forward}</code>, or</li>
* <li>this object was constructed around an explicit path, by
- * [EMAIL PROTECTED] #Forward(java.net.URI)} or [EMAIL
PROTECTED] #Forward(java.net.URL)}.</li>
+ * [EMAIL PROTECTED] #Forward(URI)} or [EMAIL PROTECTED]
#Forward(URL)}.</li>
* </ul>
*
* @return <code>true</code> if this forward does resolve to a URI path.
@@ -395,7 +389,7 @@
*/
protected ActionForward findForward( String forwardName )
{
- ActionForward fwd = ( _mapping != null ? _mapping.findForward(
forwardName ) : null );
+ ActionForward fwd = _mapping != null ? _mapping.findForward(
forwardName ) : null;
if ( fwd != null )
{
@@ -466,17 +460,13 @@
private void initFrom( ActionForward fwd )
{
- _path = fwd.getPath();
-
setContextRelative( fwd.getContextRelative() );
//
// Add query params to the path.
//
- if ( _queryString != null )
- {
- _path += _queryString.toString();
- }
+ path = fwd.getPath();
+ if ( _queryString != null ) path += _queryString.toString();
if ( fwd instanceof PageFlowActionForward )
{
@@ -504,31 +494,31 @@
if ( fc.isReturnToPage() || fc.isReturnToAction() )
{
- String path = fc.getPath();
+ String fwdPath = fc.getPath();
- if ( path.equals( RETURN_TO_PREVIOUS_PAGE_STR ) )
+ if ( fwdPath.equals( RETURN_TO_PREVIOUS_PAGE_STR ) )
{
_returnToType = RETURN_TO_PREVIOUS_PAGE;
}
- else if ( path.equals( RETURN_TO_CURRENT_PAGE_STR ) )
+ else if ( fwdPath.equals( RETURN_TO_CURRENT_PAGE_STR ) )
{
_returnToType = RETURN_TO_CURRENT_PAGE;
}
- else if ( path.equals( RETURN_TO_PAGE_LEGACY_STR ) )
+ else if ( fwdPath.equals( RETURN_TO_PAGE_LEGACY_STR ) )
{
_returnToType = RETURN_TO_PAGE; // legacy
}
- else if ( path.equals( RETURN_TO_PREVIOUS_ACTION_STR ) )
+ else if ( fwdPath.equals( RETURN_TO_PREVIOUS_ACTION_STR ) )
{
_returnToType = RETURN_TO_PREVIOUS_ACTION;
}
- else if ( path.equals( RETURN_TO_ACTION_LEGACY_STR ) )
+ else if ( fwdPath.equals( RETURN_TO_ACTION_LEGACY_STR ) )
{
_returnToType = RETURN_TO_ACTION; // legacy
}
else
{
- assert false : "invalid return-to type for forward " +
fc.getName() + ": " + path;
+ assert false : "invalid return-to type for forward " +
fc.getName() + ": " + fwdPath;
_returnToType = RETURN_TO_CURRENT_PAGE;
}
}
@@ -549,7 +539,7 @@
{
if ( _log.isDebugEnabled() )
{
- _log.debug( "using member " + retFormMember + "
for Forward " + this.getName() );
+ _log.debug( "using member " + retFormMember + "
for Forward " + getName() );
}
addOutputForm( form );
@@ -715,11 +705,11 @@
* Set the path to be returned by [EMAIL PROTECTED] #getPath}. This
overrides any path or forward name
* set in a constructor.
*
- * @param path the URI to be returned by [EMAIL PROTECTED] #getPath}.
+ * @param contextRelativePath the path to be returned by [EMAIL PROTECTED]
#getPath}.
*/
- public void setPath( String path )
+ public void setPath( String contextRelativePath )
{
- _path = path;
+ path = contextRelativePath;
_init = true;
}
@@ -741,19 +731,19 @@
/**
* Get the URI path associated with this object. Resolve it from the name
of a forward
- * (<code>@jpf:forward</code>) if necessary.
+ * (<code>@[EMAIL PROTECTED] Jpf.Forward}</code>) if necessary.
*
* @return a String that is the URI path.
- * @see #Forward(java.lang.String)
- * @see #Forward(java.lang.String, java.lang.Object)
- * @see #Forward(java.net.URI)
- * @see #Forward(java.net.URL)
+ * @see #Forward(String)
+ * @see #Forward(String, Object)
+ * @see #Forward(URI)
+ * @see #Forward(URL)
* @see #setPath
*/
public String getPath()
{
init();
- return _path;
+ return super.getPath();
}
/**
@@ -843,11 +833,11 @@
*/
public void setQueryString( String queryString )
{
- if ( queryString == null )
+ if ( queryString == null || queryString.length() == 0 )
{
_queryString = null;
}
- else if ( queryString.startsWith( "?" ) )
+ else if ( queryString.charAt( 0 ) == '?' )
{
_queryString = new StringBuilder( queryString );
}
@@ -865,16 +855,16 @@
*/
public String getQueryString()
{
- return ( _queryString != null ? _queryString.toString() : null );
+ return _queryString != null ? _queryString.toString() : null;
}
/**
* Add a query parameter to the URI returned by [EMAIL PROTECTED]
#getPath}.
*
- * @param name the name of the query parameter.
+ * @param paramName the name of the query parameter.
* @param value the value of the query parameter, or <code>null</code> if
there is no value.
*/
- public void addQueryParam( String name, String value )
+ public void addQueryParam( String paramName, String value )
{
if ( _queryString == null )
{
@@ -885,7 +875,7 @@
_queryString.append( '&' );
}
- _queryString.append( name );
+ _queryString.append( paramName );
if ( value != null )
{
@@ -896,34 +886,34 @@
/**
* Add a query parameter with no value to the URI returned by [EMAIL
PROTECTED] #getPath}.
*
- * @param name the name of the query parameter.
+ * @param paramName the name of the query parameter.
*/
- public final void addQueryParam( String name )
+ public final void addQueryParam( String paramName )
{
- addQueryParam( name, null );
+ addQueryParam( paramName, null );
}
/**
* Adds an action output that will be made available in the request,
through [EMAIL PROTECTED] PageFlowUtils#getActionOutput}.
*
* @deprecated Use [EMAIL PROTECTED] #addActionOutput} instead.
- * @param name the name of the action output.
+ * @param paramName the name of the action output.
* @param value the action output value.
*/
- public void addPageInput( String name, Object value )
+ public void addPageInput( String paramName, Object value )
{
- addActionOutput( name, value );
+ addActionOutput( paramName, value );
}
/**
* Adds an action output that will be made available in the request,
through [EMAIL PROTECTED] PageFlowUtils#getActionOutput}.
*
- * @param name the name of the action output.
+ * @param paramName the name of the action output.
* @param value the action output value.
*/
- public void addActionOutput( String name, Object value )
+ public void addActionOutput( String paramName, Object value )
{
- if ( name == null || name.length() == 0 )
+ if ( paramName == null || paramName.length() == 0 )
{
throw new IllegalArgumentException( "An action output name may not
be null or empty." );
}
@@ -939,13 +929,13 @@
//
if ( _init && getRedirect() )
{
- String actionPath = ( _mappingPath != null ? _mappingPath : "" );
- String descrip = ( getName() != null ? getName() : getPath() );
- PageFlowException ex = new IllegalActionOutputException( descrip,
actionPath, _flowController, name );
+ String actionPath = _mappingPath != null ? _mappingPath : "";
+ String descrip = getName() != null ? getName() : getPath();
+ PageFlowException ex = new IllegalActionOutputException( descrip,
actionPath, _flowController, paramName );
InternalUtils.throwPageFlowException( ex );
}
- _actionOutputs.put( name, value );
+ _actionOutputs.put( paramName, value );
}
/**
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&r1=156225&r2=156226
==============================================================================
---
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
Fri Mar 4 20:02:06 2005
@@ -48,6 +48,7 @@
import org.apache.beehive.netui.pageflow.internal.InternalUtils;
import org.apache.beehive.netui.pageflow.internal.InternalConstants;
import org.apache.beehive.netui.pageflow.internal.AdapterManager;
+import org.apache.beehive.netui.pageflow.internal.PageFlowRequestWrapper;
import org.apache.beehive.netui.script.common.ImplicitObjectUtil;
@@ -122,26 +123,21 @@
{
if ( _log.isDebugEnabled() )
{
- _log.debug( "Path " + servletPath + " does not have an
appropriate file extension. Skipping filter." );
+ _log.debug( "Path " + servletPath +
+ " does not have an appropriate file extension.
Skipping filter." );
}
chain.doFilter( request, response );
return;
}
- if ( _log.isDebugEnabled() )
- {
- _log.debug( "Filtering request for path " + servletPath );
- }
+ if ( _log.isDebugEnabled() ) _log.debug( "Filtering request for
path " + servletPath );
//
// If at an earlier stage in the request we determined that we
should prevent caching,
// actually write the appropriate headers to the response now.
//
- if ( request.getAttribute( PREVENT_CACHE_ATTR ) != null )
- {
- ServletUtils.preventCache( httpResponse );
- }
+ if ( request.getAttribute( PREVENT_CACHE_ATTR ) != null )
ServletUtils.preventCache( httpResponse );
//
// Initialize the ServletContext in the request. Often, we need
access to the ServletContext when we only
@@ -318,6 +314,15 @@
else
{
ImplicitObjectUtil.loadImplicitObjects( request, response,
_servletContext, null );
+
+ //
+ // Remove our request wrapper -- the page doesn't need to see this.
+ //
+ if ( request instanceof PageFlowRequestWrapper )
+ {
+ request = ( ( PageFlowRequestWrapper ) request ).getRequest();
+ }
+
chain.doFilter( request, response );
}
}
Modified:
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowViewHandler.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowViewHandler.java?view=diff&r1=156225&r2=156226
==============================================================================
---
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowViewHandler.java
(original)
+++
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowViewHandler.java
Fri Mar 4 20:02:06 2005
@@ -68,7 +68,7 @@
if ( request instanceof HttpServletRequest )
{
httpRequest = ( HttpServletRequest ) request;
- PreviousPageInfo prevPageInfo = PageFlowRequestWrapper.get(
httpRequest ).getPreviousPageInfo( true );
+ PreviousPageInfo prevPageInfo = PageFlowRequestWrapper.unwrap(
httpRequest ).getPreviousPageInfo( true );
if ( prevPageInfo != null )
{
Modified:
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/PageFlowRequestWrapper.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/PageFlowRequestWrapper.java?view=diff&r1=156225&r2=156226
==============================================================================
---
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/PageFlowRequestWrapper.java
(original)
+++
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/PageFlowRequestWrapper.java
Fri Mar 4 20:02:06 2005
@@ -24,6 +24,7 @@
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.ServletRequest;
+import javax.servlet.ServletRequestWrapper;
public final class PageFlowRequestWrapper
extends HttpServletRequestWrapper
@@ -47,6 +48,17 @@
public static PageFlowRequestWrapper get( ServletRequest servletRequest )
{
assert servletRequest instanceof PageFlowRequestWrapper :
servletRequest.getClass().getName();
+ return ( PageFlowRequestWrapper ) servletRequest;
+ }
+
+ public static PageFlowRequestWrapper unwrap( ServletRequest servletRequest
)
+ {
+ while ( ! ( servletRequest instanceof PageFlowRequestWrapper ) )
+ {
+ assert servletRequest instanceof ServletRequestWrapper :
servletRequest.getClass().getName();
+ servletRequest = ( ( ServletRequestWrapper ) servletRequest
).getRequest();
+ }
+
return ( PageFlowRequestWrapper ) servletRequest;
}