In JSF 2.0 <h:link> tags were introduced that allow users to navigate to a JSF page without using a postback request.
For example:
<h:link value="3 Month Subscription" outcome="subscribe" />
would create an HTML link similar to:
<a href="/MyApp/faces/subscribe.xhtml">3 Month Subscription</a>
The value of the “outcome” parameter utilizes JSF 2.0 implicit navigation rules that save you the trouble of defining navigation cases in the faces-config.xml file.
Furthermore query parameters may be added to the links:
<h:link value="3 Month Subscription" outcome="subscribe">
<f:param name="subscriptionType" value="threeMonth" />
</h:link>
<h:link value="6 Month Subscription" outcome="subscribe">
<f:param name="subscriptionType" value="sixMonth" />
</h:link>
The links would look like this:
<a href="/MyApp/faces/subscribe.xhtml?subscriptionType=threeMonth">3 Month Subscription</a>
<a href="/MyApp/faces/subscribe.xhtml?subscriptionType=sixMonth">6 Month Subscription</a>
This way we are able to preset the subscription type field on the subscribe.xhtml page. In subscribe.xhtml there might be the following Radio Buttons:
<h:selectOneRadio label="Subscription Type" value="#{BackingBean.subscriptionType}" id="subscriptionType">
<f:selectItem itemLabel="3 Month Subscription" itemValue="threeMonth" />
<f:selectItem itemLabel="6 Month Subscription" itemValue="sixMonth" />
</h:selectOneRadio>
Instead of representing the subscription type value as radio buttons you could use any other input component including for example a hidden field.
In order for the radio button to be selected upon loading the subscribe.xhtml page you must add the following annotation to the subscriptionType field in the corresponding JSF managed bean:
[...]
@ManagedProperty(value="#{param.subscriptionType}")
private String subscriptionType;
[...]
