You need the <f:param> in the UICommand component to retain request parameters for the subsequent request. E.g.
<p:commandButton ...>
<f:param name="project" value="#{param.project}" />
</p:commandButton>
Alternatively, you can use the <o:form> of the JSF utility library OmniFaces, it basically extends the <h:form>
with an additional attribute includeViewParams
which enables you to retain request parameters registered via <f:viewParam>
for the subsequent request.
<o:form includeViewParams="true">
...
</o:form>
This may end up to be easier if you have multiple command buttons/links and ajax actions.
The URL in browser address bar is in your case not changed because you're firing an ajax request. But the actual URL, which you can see in <form action>
of the generated HTML output via rightclick - View Source in browser, does by default not contain the current GET parameters.
Unrelated to the concrete problem, with manually collecting the parameter in postconstruct, you're basically ignoring the usefulness and powers of the <f:viewParam>
. I recommend to carefully go through the following answers to learn how to utilize them properly:
- What can <f:metadata>, <f:viewParam> and <f:viewAction> be used for?
- ViewParam vs @ManagedProperty(value = "#{param.id}")