Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support view actions that execute before tree is built w/ navigation support #758

Closed
eclipse-faces-bot opened this issue Mar 3, 2010 · 31 comments

Comments

@eclipse-faces-bot
Copy link

JSF should provide a view metadata component that defines a method expression to
be invoked before the component tree is built (or restored), with support for
navigating to an alternative view afterward using navigation rules. Navigation
may be the result of a constraint violation, a security restriction, or because
the request was for a pseudo-view.

As an example, the developer might use a view action to load a blog entry before
the view is displayed. If the entry cannot be found, the user would be
redirected to another page using a navigation rule.

<f:view>
<f:metadata>
<f:viewParam name="id" value="#

{blogController.id}

"/>
<f:viewAction execute="#

{blogController.loadEntry}" onPostback="false"/>
</f:metadata>
</f:view>

#{blogController.loadEntry} false /entries.xhtml

This feature relates to view parameters, as the example suggests. View
parameters were introduced in JSF 2.0 to provide a declarative value binding
between query string parameters and model properties. They go a long way towards
accommodating the action-oriented scenario in JSF. But view actions are a
necessary part of the equation.

<f:event type="preRenderView"> is similar to <f:viewAction>, but is insuffient
as a front controller. <f:event> gets you by if the purpose is to perform
processing at the start of the request. <f:viewAction> is intended for when you
have to perform logic to verify that the view can even be rendered. View-level
security is one example. Another is verifying that preconditions are met. And
the key is to make navigation away from the view an integrated part when it's
determined that the view cannot and should not be rendered.

Environment

Operating System: All
Platform: All
URL: http://seamframework.org/Documentation/JSFEnhancementViewActions

Affected Versions

[2.0]

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
Reported by mojavelinux

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
mojavelinux said:
Change target milestone.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
mojavelinux said:
Andy Schwartz clarifies:

1. View actions would be processed during invoke application phase.
PreRenderView events are delivered during the render response phase.

2. View actions would be integrated with the navigation system (allow navigation
rules to be applied). PreRenderView events require programmatic interaction with
the NavigationHandler.

3. View actions would be part of the view metadata (like view parameters) and
thus would be available before the full component tree has been created.
PreRenderView event listeners are registered (via <f:event>) when the full
component tree is created.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
sheetalv

@eclipse-faces-bot
Copy link
Author

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
jkva said:

      • Issue 867 has been marked as a duplicate of this issue. ***

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
rogerk said:
triage

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
Bulk assign all of Sheetal's spec issues to me.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
Move viewParameters automated test to jsf-test

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
In progress.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
Brian, if you could please hack upon this and make it a simple sample of s:viewAction, I'd really appreciate it.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
Brian, if you could please simply hack upon this and turn it into a simple example of s:viewAction, that would be great.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
File: 20110615_i_spec_758.patch
Attached By: @edburns

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
Sending jsf-api/build.xml
Adding jsf-api/doc/expert-draft-bg.graffle
Adding jsf-api/doc/expert-draft-bg.png
Adding jsf-api/doc/jsdoc-template
Adding jsf-api/doc/jsdoc-template/static
Adding jsf-api/doc/jsdoc-template/static/default.css
Sending jsf-api/doc/standard-html-renderkit-base.xml
Sending jsf-api/doc/standard-html-renderkit.xml
Adding jsf-api/doc/uiviewaction-props.xml
Adding jsf-api/src/main/java/javax/faces/component/UIViewAction.java
Sending jsf-api/src/main/java/javax/faces/context/ExternalContextWrapper.java
Sending jsf-api/src/main/java/javax/faces/event/PhaseId.java
Sending jsf-api/src/main/resources/jsf-api.css
Sending jsf-demo/build.xml
Sending jsf-ri/build.xml
Sending jsf-ri/conf/share/facelets_jsf_core.taglib.xml
Sending jsf-ri/conf/share/facelets_jsf_core.tld
Sending jsf-ri/conf/share/tlddoc-resources/stylesheet.css
Sending jsf-ri/src/main/java/com/sun/faces/facelets/tag/jsf/ComponentSupport.java
Sending jsf-ri/src/main/java/com/sun/faces/facelets/tag/jsf/core/CoreLibrary.java
Adding jsf-test/#758
Adding jsf-test/#758/build.xml
Adding jsf-test/#758/i_spec_758_htmlunit
Adding jsf-test/#758/i_spec_758_htmlunit/pom.xml
Adding jsf-test/#758/i_spec_758_htmlunit/src
Adding jsf-test/#758/i_spec_758_htmlunit/src/main
Adding jsf-test/#758/i_spec_758_htmlunit/src/main/java
Adding jsf-test/#758/i_spec_758_htmlunit/src/main/java/com
Adding jsf-test/#758/i_spec_758_htmlunit/src/main/java/com/sun
Adding jsf-test/#758/i_spec_758_htmlunit/src/main/java/com/sun/faces
Adding jsf-test/#758/i_spec_758_htmlunit/src/main/java/com/sun/faces/regression
Adding jsf-test/#758/i_spec_758_htmlunit/src/main/java/com/sun/faces/regression/i_spec_758
Adding jsf-test/#758/i_spec_758_htmlunit/src/main/java/com/sun/faces/regression/i_spec_758/Issue758TestCase.java
Adding jsf-test/#758/i_spec_758_war
Adding jsf-test/#758/i_spec_758_war/pom.xml
Adding jsf-test/#758/i_spec_758_war/src
Adding jsf-test/#758/i_spec_758_war/src/main
Adding jsf-test/#758/i_spec_758_war/src/main/java
Adding jsf-test/#758/i_spec_758_war/src/main/java/com
Adding jsf-test/#758/i_spec_758_war/src/main/java/com/sun
Adding jsf-test/#758/i_spec_758_war/src/main/java/com/sun/faces
Adding jsf-test/#758/i_spec_758_war/src/main/java/com/sun/faces/regression
Adding jsf-test/#758/i_spec_758_war/src/main/java/com/sun/faces/regression/i_spec_758
Adding jsf-test/#758/i_spec_758_war/src/main/java/com/sun/faces/regression/i_spec_758/NewsIndex.java
Adding jsf-test/#758/i_spec_758_war/src/main/java/com/sun/faces/regression/i_spec_758/NewsReader.java
Adding jsf-test/#758/i_spec_758_war/src/main/java/com/sun/faces/regression/i_spec_758/NewsStory.java
Adding jsf-test/#758/i_spec_758_war/src/main/webapp
Adding jsf-test/#758/i_spec_758_war/src/main/webapp/WEB-INF
Adding jsf-test/#758/i_spec_758_war/src/main/webapp/WEB-INF/faces-config.xml
Adding jsf-test/#758/i_spec_758_war/src/main/webapp/WEB-INF/web.xml
Adding jsf-test/#758/i_spec_758_war/src/main/webapp/events.xhtml
Adding jsf-test/#758/i_spec_758_war/src/main/webapp/page01.xhtml
Adding jsf-test/#758/i_spec_758_war/src/main/webapp/page02.xhtml
Adding jsf-test/#758/i_spec_758_war/src/main/webapp/page03.xhtml
Adding jsf-test/#758/i_spec_758_war/src/main/webapp/template.xhtml
Sending jsf-test/build.xml
Sending jsf-tools/src/main/resources/com/sun/faces/generate/facesdoc/stylesheet.css
Transmitting file data ................................
Committed revision 9173.

Checkpoint. Specified but not implemented.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
snapshot. Brian Leathem's simple testcase works.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
File: 20110729-01-i_spec_758.patch
Attached By: @edburns

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
Snapshot, sample app based on Dan Allen's original NewsReader testcase works.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
File: 20110810-i_spec_758.patch
Attached By: @edburns

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
Snapshot to run automated tests on ADC machine.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
The i_spec_915 testcase caught a mod in this changebundle that introduced breakage. The jsf-ri-config.xml does not need to be modified and I'm not sure why it was. Victory for automated tests.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
Resolution attempt one realized http://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-758

SECTION: Modified Files

M applicationIntegration.fm

  • 7.4.2 Rewrite the paragraph on how to handle a redirect as follows.

If a matching element was located, and the
element was specified in this

  • or a call to UIViewAction.isProcessingBroadcast() returns true,

call getRedirectURL() on the ViewHandler, passing the current
FacesContext, the , any name=value parameter pairs
specified within elements within the element,
and the value of the include-view-params attribute of the
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.

  • If the preceding call to UIViewAction.isProcessingBroadcast() had
  • returned true, also call setKeepMessages(true) on the flash.

Call responseComplete() on the FacesContext instance for the current
request. If the content of 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

  • complete spec for this feature

  • rename "if" attribute of f:viewAction to "rendered".

M jsf-ri/conf/share/facelets_jsf_core.tld

  • rename "if" attribute of f:viewAction to "rendered".

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

  • implement changes to 7.4.2

M jsf-test/#758/build.xml
M jsf-test/#758/i_spec_758_war/src/main/java/com/sun/faces/regression/i_spec_758/NewsReader.java
M jsf-test/#758/i_spec_758_war/src/main/webapp/page02.xhtml

A jsf-test/#758/i_spec_758_simple_war
A jsf-test/#758/i_spec_758_simple_war/src
A jsf-test/#758/i_spec_758_simple_war/src/main
A jsf-test/#758/i_spec_758_simple_war/src/main/java
A jsf-test/#758/i_spec_758_simple_war/src/main/java/com
A jsf-test/#758/i_spec_758_simple_war/src/main/java/com/sun
A jsf-test/#758/i_spec_758_simple_war/src/main/java/com/sun/faces
A jsf-test/#758/i_spec_758_simple_war/src/main/java/com/sun/faces/regression
A jsf-test/#758/i_spec_758_simple_war/src/main/java/com/sun/faces/regression/i_spec_758_simple_war
A jsf-test/#758/i_spec_758_simple_war/src/main/java/com/sun/faces/regression/i_spec_758_simple_war/ViewActionTestBean.java
A jsf-test/#758/i_spec_758_simple_war/src/main/webapp
A jsf-test/#758/i_spec_758_simple_war/src/main/webapp/main.xhtml
A jsf-test/#758/i_spec_758_simple_war/src/main/webapp/WEB-INF
A jsf-test/#758/i_spec_758_simple_war/src/main/webapp/WEB-INF/web.xml
A jsf-test/#758/i_spec_758_simple_war/src/main/webapp/result.xhtml
A jsf-test/#758/i_spec_758_simple_war/pom.xml
A + jsf-test/#758/i_spec_758_htmlunit/src/main/java/com/sun/faces/regression/i_spec_758/Issue758SimpleTestCase.java

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
File: 20110812-i_spec_758.patch
Attached By: @edburns

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
Sending jsf-api/src/main/java/javax/faces/component/UIViewAction.java
Sending jsf-ri/conf/share/facelets_jsf_core.tld
Sending jsf-ri/src/main/java/com/sun/faces/application/NavigationHandlerImpl.java
Sending jsf-test/#758/build.xml
Adding jsf-test/#758/i_spec_758_htmlunit/src/main/java/com/sun/faces/regression/i_spec_758/Issue758SimpleTestCase.java
Adding jsf-test/#758/i_spec_758_simple_war
Adding jsf-test/#758/i_spec_758_simple_war/pom.xml
Adding jsf-test/#758/i_spec_758_simple_war/src
Adding jsf-test/#758/i_spec_758_simple_war/src/main
Adding jsf-test/#758/i_spec_758_simple_war/src/main/java
Adding jsf-test/#758/i_spec_758_simple_war/src/main/java/com
Adding jsf-test/#758/i_spec_758_simple_war/src/main/java/com/sun
Adding jsf-test/#758/i_spec_758_simple_war/src/main/java/com/sun/faces
Adding jsf-test/#758/i_spec_758_simple_war/src/main/java/com/sun/faces/regression
Adding jsf-test/#758/i_spec_758_simple_war/src/main/java/com/sun/faces/regression/i_spec_758_simple_war
Adding jsf-test/#758/i_spec_758_simple_war/src/main/java/com/sun/faces/regression/i_spec_758_simple_war/ViewActionTestBean.java
Adding jsf-test/#758/i_spec_758_simple_war/src/main/webapp
Adding jsf-test/#758/i_spec_758_simple_war/src/main/webapp/WEB-INF
Adding jsf-test/#758/i_spec_758_simple_war/src/main/webapp/WEB-INF/web.xml
Adding jsf-test/#758/i_spec_758_simple_war/src/main/webapp/main.xhtml
Adding jsf-test/#758/i_spec_758_simple_war/src/main/webapp/result.xhtml
Sending jsf-test/#758/i_spec_758_war/src/main/java/com/sun/faces/regression/i_spec_758/NewsReader.java
Sending jsf-test/#758/i_spec_758_war/src/main/webapp/page02.xhtml
Transmitting file data ............
Committed revision 9254.

Sending applicationIntegration.fm
Sending preface.fm
Transmitting file data ..
Committed revision 1027.

Committed to trunk.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
snapshot

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
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 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 of the

  • matching . If they differ, take any necessary actions

  • to effectively restart the JSF lifecycle on the of the

  • matching . 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 was specified

  • on the matching . If the viewIds do not differ,

  • continue on to the next bullet point.

    • If the element was not specified in this
      (or the application is running in a Portlet environment, where
      redirects are not possible), use the 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 is a
      value expression, first evaluate it to obtain the value of the view
      id.
    • If the element was specified in this ,
      call getRedirectURL() on the ViewHandler, passing the current
      FacesContext, the , any name=value parameter pairs
      specified within elements within the element,
      and the value of the include-view-params attribute of the
      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 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/#758/i_spec_758_simple_war/src/main/java/com/sun/faces/regression/i_spec_758_simple_war/ViewActionTestBean.java
A + jsf-test/#758/i_spec_758_simple_war/src/main/webapp/pageAviewActionPageA.xhtml
A + jsf-test/#758/i_spec_758_simple_war/src/main/webapp/pageAviewActionEmpty.xhtml
A + jsf-test/#758/i_spec_758_simple_war/src/main/webapp/pageAviewActionPageAExplicitRedirect.xhtml
A jsf-test/#758/i_spec_758_simple_war/src/main/webapp/WEB-INF/faces-config.xml
A + jsf-test/#758/i_spec_758_simple_war/src/main/webapp/pageAviewActionNull.xhtml
M jsf-test/#758/i_spec_758_htmlunit/src/main/java/com/sun/faces/regression/i_spec_758/Issue758SimpleTestCase.java
D jsf-test/#758/i_spec_758_htmlunit/src/main/java/com/sun/faces/regression/i_spec_758/Issue758TestCase.java
A + jsf-test/#758/i_spec_758_htmlunit/src/main/java/com/sun/faces/regression/i_spec_758/ViewParametersTestCase.java
M jsf-test/#758/build.xml

  • Exercise corner cases, also HtmlUnit test for ViewParameters

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
Committed frame changes.

Sending applicationIntegration.fm
Transmitting file data .
Committed revision 1028.
Rhombus:frame edburns$

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
lamine_ba said:
Hi,

Regarding the instruction below

<f:view>
<f:metadata>

<f:viewParam name="id" value="#{blogController.id}"/>
<f:viewAction execute="#{blogController.loadEntry}" onPostback="false"/>

</f:metadata>
</f:view>

I'm wondering if we could have this short variation

<f:view>
<f:metadata>

<f:viewAction param-name="id" param-value="#{blogController.id}" 
execute="#{blogController.loadEntry}" onPostback="false"/>

</f:metadata>
</f:view>

Thanks

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
Closed pending verification of implementation.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
Leo found some additional work for this issue.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@arjantijms said:
Now that the JSF 2.2 spec has been finalized, shouldn't this issue be closed as well?

@eclipse-faces-bot
Copy link
Author

@eclipse-faces-bot eclipse-faces-bot added this to the 2.2 milestone Aug 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant