7.4. Propagating request parameters
If only the
name
attribute is specified, the request parameter is propagated with the PAGE
context (that is, it is not mapped to model property).
<pages> <page view-id="/hello.jsp" action="#{helloWorld.sayHello}"> <param name="firstName" /> <param name="lastName" /> </page> </pages>
Page parameter propagation is especially useful when building multi-layered master-detail CRUD pages. You can use it to "remember" your view (for example, when pressing the Save button), and which entity you were editing.
- Any
<s:link>
or<s:button>
transparently propagates the request parameter if that parameter is listed as a page parameter for the view. - The value is transparently propagated with any JSF form submission for the page with the given view ID. (This means that view parameters behave like
PAGE
-scoped context variables for Faces requests.
Although this is fairly complex, it is definitely worthwhile to dedicate time to an understanding of page parameters. They are the most elegant method of propagating state across non-Faces requests. They are particularly useful in certain situations. For example, if we have search screens with bookmarkable results pages, page parameters let us write handling for both POST and GET requests in the same code. Page parameters eliminate repetitive request parameter-listing in the view definition, and simplify redirect code.