HTML and CSS Reference
In-Depth Information
Listing 4-31. JSF Input Form for Entering Car Information (intro.xhtml)
<h:panelGrid columns="3">
<h:outputText value="Model:"></h:outputText>
<h:inputText id="model"
requiredMessage="You need to specify car model">
<h:message for="model" styleClass="errorMessage"/>
<h:outputText value="Color:"></h:outputText>
<h:inputText id="color"
requiredMessage="You need to specify car color">
<h:message for="color" styleClass="errorMessage"/>
<h:outputText value="Car Number:"></h:outputText>
<h:inputText id="number"
requiredMessage="You need to specify car number">
<f:validateLongRange minimum="1" maximum="9999999999"/>
<h:message for="number" styleClass="errorMessage"/>
<h:commandButton value="View car details"
action="car?faces-redirect=true&amp;includeViewParams=true" />
As shown in the bolded lines, in order to allow the JSF command button to navigate to our RESTful page (car.
xhtml) in a RESTful way (target page name and parameters will appear in the browser address bar), we need to add
the following two parameters to action outcome of UICommand :
1. faces-redirect : setting faces-redirect parameter to true allows the current page to be
redirected (not forwarded) to the target page (as we know from Chapter 2).
2. includeViewParams : setting includeViewParams to true inside the action outcome allows
ActionSource2 component to include view parameters when performing navigation. Keep
in mind that the included view parameters must be declared in the target JSF page, which
is ( car.xhtml ) in our example.
Assuming that valid data are entered in the intro.xhtml page and then the "View car details" button is
clicked, the page will be redirected to ( car.xhtml ) page with the following parameters in the browser address bar:
Search WWH ::

Custom Search