jsr344-experts@javaserverfaces-spec-public.java.net

[jsr344-experts] Re: [758-ViewActions] Realization of Resolution Attempt One

From: Ed Burns <edward.burns_at_oracle.com>
Date: Thu, 18 Aug 2011 12:08:27 -0700

>>>>> On Wed, 17 Aug 2011 19:00:52 -0700, Brian Leathem <bleathem_at_gmail.com> said:

>>
>> https://maven.java.net/service/local/repositories/snapshots/archive/javax/faces/javax.faces-api/2.2-SNAPSHOT/javax.faces-api-2.2-20110813.023226-2-javadoc.jar/!/javax/faces/component/UIViewAction.html

BL> This line from the Seam Faces UIViewAction documentation would be a good
BL> addition to the javadoc:
BL> "If the value of the component'simmediateattribute istrue, the action
BL> will be invoked during the Apply Request Values JSF lifecycle phase.
BL> Otherwise, the action will be invoked during the Invoke Application
BL> phase, the default behavior. The phase can be set explicitly in
BL> thephaseattribute, which takes precedence over theimmediateattribute."

Thanks. Done.

EB> * 7.4.2 Rewrite the paragraph on how to handle a redirect as follows.

EB> If a matching<navigation-case> element was located, and the
EB> <redirect/> element was specified in this<navigation-case>

EB> + or a call to UIViewAction.isProcessingBroadcast() returns true,

BL> To me, it seems unfortunate that we force a redirect. Do we have to
BL> require this redirect explicitly in the specification? Can we instead
BL> leave ourselves a way out in the future, should use-cases present
BL> themselves that warrant an internal forward (server-side redirect)?

The implementation of s:viewAction had some very complicated logic to
re-start the JSF lifecycle. A redirect seemed the simplest way to meet
the requirement to re-start the lifecycle. A
RequestDispatcher.forward() does not meet the requirement of re-starting
the JSF lifecycle. I could reformulate the spec language to say that the
JSF lifecycle must be restarted, instead of explicitly calling for a
redirect. Also, I ntote that in a portlet environment, redirects are
not possible anyway. Let's try it.

Here is a new changebundle.

Corner cases on using viewAction to go back to the same page http://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-758

SECTION: Modified Files
----------------------------
M applicationIntegration.fm

    * 7.4.2 now has this text

If a matching <navigation-case> element was located, proceed as follows.

+ * If UIViewAction.isProcessingBroadcast() returns true, call
+ getFlash().setKeepMessages(true) on the current FacesContext. Compare
+ the viewId of the current viewRoot with the <to-view-id> of the
+ matching <navigation-case>. If they differ, take any necessary actions
+ to effectively restart the JSF lifecycle on the<to-view-id> of the
+ matching <navigation-case>. Care must be taken to preserve any view
+ parameters or navigation case parameters, clear the view map of the
+ UIViewRoot, and call setRenderAll(true) on the
+ PartialViewContext. Implementations may choose to meet this
+ requirement by treating this case as if a <redirect /> was specified
+ on the matching <navigation-case>. If the viewIds do not differ,
+ continue on to the next bullet point.

+ * If the <redirect/> element was not specified in this <navigation-case>
(or the application is running in a Portlet environment, where
redirects are not possible), use the <to-view-id> element of the
matching case to request a new UIViewRoot instance from the
ViewHandler instance for this application, and pass it to the
setViewRoot() method of the FacesContext instance for the current
request. Then, exit the algorithm. If the content of <to-view-id> is a
value expression, first evaluate it to obtain the value of the view
id.

+ * If the <redirect/> element was specified in this <navigation-case>,
call getRedirectURL() on the ViewHandler, passing the current
FacesContext, the <to-view-id>, any name=value parameter pairs
specified within <view-param> elements within the <redirect> element,
and the value of the include-view-params attribute of the <redirect />
element if present, false, if not. The return from this method is the
value to be sent to the client to which the redirect will occurr. Call
getFlash().setRedirect(true) on the current FacesContext. Cause the
current response to perform an HTTP redirect to this path, and call
responseComplete() on the FacesContext instance for the current
request. If the content of <to-view-id> is a value expression, first
evaluate it to obtain the value of the view id.

M jsf-api/src/main/java/javax/faces/component/UIViewAction.java

    * Fix logic error that would cause multiple f:actionEvents to fail.

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

    * Implement new 7.4.2 spec

M jsf-test/build.xml

    * wire up testcases

M jsf-test/JAVASERVERFACES_SPEC_PUBLIC-758/i_spec_758_simple_war/src/main/java/com/sun/faces/regression/i_spec_758_simple_war/ViewActionTestBean.java
A + jsf-test/JAVASERVERFACES_SPEC_PUBLIC-758/i_spec_758_simple_war/src/main/webapp/pageAviewActionPageA.xhtml
A + jsf-test/JAVASERVERFACES_SPEC_PUBLIC-758/i_spec_758_simple_war/src/main/webapp/pageAviewActionEmpty.xhtml
A + jsf-test/JAVASERVERFACES_SPEC_PUBLIC-758/i_spec_758_simple_war/src/main/webapp/pageAviewActionPageAExplicitRedirect.xhtml
A jsf-test/JAVASERVERFACES_SPEC_PUBLIC-758/i_spec_758_simple_war/src/main/webapp/WEB-INF/faces-config.xml
A + jsf-test/JAVASERVERFACES_SPEC_PUBLIC-758/i_spec_758_simple_war/src/main/webapp/pageAviewActionNull.xhtml
M jsf-test/JAVASERVERFACES_SPEC_PUBLIC-758/i_spec_758_htmlunit/src/main/java/com/sun/faces/regression/i_spec_758/Issue758SimpleTestCase.java
D jsf-test/JAVASERVERFACES_SPEC_PUBLIC-758/i_spec_758_htmlunit/src/main/java/com/sun/faces/regression/i_spec_758/Issue758TestCase.java
A + jsf-test/JAVASERVERFACES_SPEC_PUBLIC-758/i_spec_758_htmlunit/src/main/java/com/sun/faces/regression/i_spec_758/ViewParametersTestCase.java
M jsf-test/JAVASERVERFACES_SPEC_PUBLIC-758/build.xml

    * Exercise corner cases, also HtmlUnit test for ViewParameters


-- 
| edward.burns_at_oracle.com | office: +1 407 458 0017
| homepage:               | http://ridingthecrest.com/
| 27 business days until JSF 2.2 Early Draft Review
| 31 business days until JavaOne 2011