dev@javaserverfaces.java.net

Seeking Review: ViewHandler.restoreView() clarification

From: Ed Burns <Ed.Burns_at_Sun.COM>
Date: Fri, 05 Nov 2004 08:07:12 -0800

Fix for part one.

Issue: jsf-spec11

This change bundle modifies the javadoc for ViewHandler.restoreView() to
clarify what should happen in the initial request to
ViewHandler.restoreView().

SECTION: API Changes

M jsf-api/src/javax/faces/application/ViewHandler.java

+ * If this is an
+ * initial request to the faces system, this method must return
+ * null.

SECTION: RI changes

M jsf-ri/src/com/sun/faces/application/ViewHandlerImpl.java

- implement the above spec change. Note that the systest called
  com.sun.faces.pathtest.PathTest exercises this code.

SECTION: API diffs

Index: jsf-api/src/javax/faces/application/ViewHandler.java
===================================================================
RCS file:
/cvs/javaserverfaces-sources/jsf-api/src/javax/faces/application/ViewHandler.java,v
retrieving revision 1.39
diff -u -r1.39 ViewHandler.java
--- jsf-api/src/javax/faces/application/ViewHandler.java 5 Apr 2004 18:25:59
-0000 1.39
+++ jsf-api/src/javax/faces/application/ViewHandler.java 5 Nov 2004 15:50:24 -0000
@@ -172,10 +172,12 @@
     /**
      * <p>Perform whatever actions are required to restore the view
      * associated with the specified {_at_link FacesContext} and
- * <code>viewId</code>. It may delegate to the <code>restoreView</code>
- * of the associated {_at_link StateManager} to do the actual work of
- * restoring the view. If there is no available state for the
- * specified <code>viewId</code>, return <code>null</code>.</p>
+ * <code>viewId</code>. It may delegate to the
+ * <code>restoreView</code> of the associated {_at_link StateManager}
+ * to do the actual work of restoring the view. If this is an
+ * initial request to the faces system, this method must return
+ * null. If there is no available state for the specified
+ * <code>viewId</code>, return <code>null</code>.</p>
      *
      * @param context {_at_link FacesContext} for the current request
      * @param viewId the view identifier for the current request

SECTION: RI diffs

Index: jsf-ri/src/com/sun/faces/application/ViewHandlerImpl.java
===================================================================
RCS file:
/cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/application/ViewHandlerImpl.java,v
retrieving revision 1.45
diff -u -r1.45 ViewHandlerImpl.java
--- jsf-ri/src/com/sun/faces/application/ViewHandlerImpl.java 5 Aug 2004
20:02:19 -0000 1.45
+++ jsf-ri/src/com/sun/faces/application/ViewHandlerImpl.java 5 Nov 2004
15:50:26 -0000
@@ -204,7 +204,7 @@
             viewId = convertViewId(context, viewId);
         }
         
- // maping could be null if a non-faces request triggered
+ // mapping could be null if a non-faces request triggered
         // this response.
         if (extContext.getRequestPathInfo() == null && mapping != null &&
             isPrefixMapped(mapping)) {
@@ -220,14 +220,19 @@
                 throw new FacesException(ioe);
             }
         } else {
- // this is necessary to allow decorated impls.
- ViewHandler outerViewHandler =
- context.getApplication().getViewHandler();
- String renderKitId =
- outerViewHandler.calculateRenderKitId(context);
- viewRoot = Util.getStateManager(context).restoreView(context,
- viewId,
- renderKitId);
+ // only try to restore the view if this is not an initial
+ // request
+ if (!extContext.getRequestParameterMap().isEmpty()) {
+ // this is necessary to allow decorated impls.
+ ViewHandler outerViewHandler =
+ context.getApplication().getViewHandler();
+ String renderKitId =
+ outerViewHandler.calculateRenderKitId(context);
+ viewRoot =
+ Util.getStateManager(context).restoreView(context,
+ viewId,
+ renderKitId);
+ }
         }
 
         return viewRoot;
-- 
| ed.burns_at_sun.com  | {home: 407 294 2468, office: 408 884 9519 OR x31640}
| homepage:         | http://javaweb.sfbay.sun.com/~edburns/
| aim: edburns0sunw | iim: ed.burns_at_sun.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net