chapter 6 - the navigation model
--------------------------------
action attribute
h:commandButton
h:commandLink
outcome attribute
h:button
h:link
in MVC the Faces Servlet acts as the controller
an event triggered by a component which implements ActionSource interface
-> navigation event -> NavigationHandler
component that implements ActionSource2 interface means that this
component is the source of an ActionEvent
apply request values - triggering an ActionEvent
invoke application - the default ActionListener.processAction is called
which calls the action method and generates an outcome
after that NavigationHandler.handleNavigation is called if outcome not null
which does FacesContext.setViewRoot(new UIViewRoot())
if outcome null or not a valid outcome - user remains on the same page
this usually results in RequestDispatcher.forward() being called
<if>#{model.booleanValue}</if>
redirect means that you generate another request
<navigation-case>
<from-action>#{Login.loginAction}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>/success.xhtml</to-view-id>
<redirect/>
</navigation-case>
h:button and h:link do GET
h:commandButton and h:commandLink do POST
h:commandButton value="HTTP POST with Redirect" action="page02?facesredirect=true"
---------------------------------------
<f:metadata>
<f:viewParam name="fname" value="#{userBean.firstName}" />
<f:viewParam name="lname" value="#{userBean.lastName}" />
<f:viewParam name="sex" value="#{userBean.sex}" />
<f:viewParam name="dob" value="#{userBean.dob}">
<f:convertDateTime pattern="MM-dd-yy" />
</f:viewParam>
<f:viewParam name="email" value="#{userBean.email}" />
<f:viewParam name="sLevel" value="#{userBean.serviceLevel}" />
</f:metadata>
<navigation-rule>
<from-view-id>whatever the from view id is</from-view-id>
<navigation-case>
<from-outcome>whatever the outcome value is</from-outcome>
<to-view-id>whatever the to view id is</to-view-id>
<redirect>
...the view-param elements are optional
<view-param>
<name>any string is fine here</name>
<value>any string or value expression is fine here</value>
</view-param>
...additional view-param elements may be defined
</redirect>
</navigation-case>
</navigation-rule>
<error-page>
<exception-type>javax.faces.application.ViewExpiredException
</exception-type>
<location>/faces/sessionExpired.xhtml</location>
</error-page>
<error-page>
<exception-type>com.jsfcompref.BadUserException
</exception-type>
<location>/faces/badUser.xhtml</location>
</error-page>
The UI component tree is fully managed by the ViewHandler between requests. However, it is
the role of the StateManager to preserve the UI component tree in between subsequent
requests. It saves the complete status of the component tree using one of several different statesaving
methods specified as a context parameter (javax.faces.STATE_SAVING_METHOD) in
the Web application’s web.xml file. The different state-saving parameters are server and client.
------------------------
chapter 7 - the user interface component model
ActionSource2
ValueHolder
PartialStateHolder
NamingContainer
No comments:
Post a Comment