Monday, June 14, 2010

Bookmarkable URLs with JSF2

Parameters are now defined in the page itself so a request like:


would have its parameters defined as

        <f:viewParam name="contactId" value="#{}"/>

If the parameter value isn't specified in the request then the value will be null, so make sure the property receiving the parameter value isn't a primitive (i.e. it must be nullable).

You will also need an action to load data into the view. Any component can have pre-render events attached to it. For example, a form:

<h:form id="contactInfoForm">
            <f:event type="preRenderComponent" listener="#{contactController.loadContact}"/>

All you need to do is declare the parameters to be bound and the action on the page/view you wish to make bookmarkable.

No comments:

Post a Comment