My current environment is JRE 1.7, JSF 2.2, Eclipse Luna. In a certain page (entity_index.xhtml
) of my application I have the following (PrimeFaces) button:
p:commandButton
performs a POST request. You want simply to GET a view with your entity detail, not to POST the server, so you need a h:link
:
<h:link value="Details" outcome="entity_details" target="_blank">
<f:param name="id" value="#{entity.id}" />
</h:link>
Then, the f:viewParam
in the destination page will be able to process the url parameter:
<f:metadata>
<f:viewParam name="id" value="#{entityDetailsMB.id}"/>
<f:viewAction action="#{entityDetailsMB.init}" />
</f:metadata>
Use a f:viewAction
to initialize your entity instead of doing it in a getter, which is discouraged:
public void init(){
entity = entityById(id);
}
See also: