The difference for me (according to Jason) is that I use JSF 2.0. I read that JSF 2.0 added the ability to use get, but I'm not sure which is the right way to use this.
Please note that this is not the same as maintaining Ajax state. This usually happens with fragment identifiers (the part starting with #
in the URL, also known as hashbang). JSF does not offer built-in components / functions for this. As far as I have not seen the component library that does this. However, you can find this answer to get started with the fragmented hash fragment processor in JSF.
Regarding the use of GET requests, just use <h:link>
, <h:outputLink>
or even <a>
to create GET links. You can specify query parameters in h:
components on <f:param>
. For instance.
<h:link value="Edit product" outcome="product/edit"> <f:param name="id" value="#{product.id}" /> </h:link>
On the product/edit.xhtml
you can define parameters for installation and actions for execution upon request by GET
<f:metadata> <f:viewParam name="id" value="#{productEditor.id}" /> <f:event type="preRenderView" listener="#{productEditor.init}" /> </f:metadata>
In the request or presentation area limited by the bean associated with the product/edit.xhtml
- in this example #{productEditor}
-, you simply define the properties and method of the listener. The listener method will be executed after all the properties are collected, converted, validated and updated in the model.
private Long id; private Product product; public void init() { product = productService.find(id); }
source share