I have simple jsf page with view params and load method which is processing those params:
<f:metadata>
<f:viewParam name="param1" value="#{bean.param1}"/>
<f:viewParam name="param2" value="#{bean.param2}"/>
<f:viewParam name="param3" value="#{bean.param3}"/>
<f:event type="preRenderView" listener="#{bean.load()}"/>
</f:metadata>
I also set some initial values in @PostConstruct
.
How to redirect user to new location that include those parameters (which are not null).
For example user enter in browser:
domain.com/page.jsf
and is redirected to:
domain.com/page.jsf?param1=valueA
because param1 was set in @PostConstruct
.
Another question - I have links on page referencing same view:
<h:link value="clickme">
<f:param name="param3" value="otherValue"/>
</h:link>
When user enters page with ?param1=someValue
and clicks link, got redirected to ?param3=otherValue
but I want to redirect to ?param1=someValue¶m3=otherValue
.
I know I can add more parameters in <h:link>
but it's diffucult to add every possible param in every <h:link>
PS. I use BalusC tip from this topic JSF 2 and Post/Redirect/Get?
outcome += "&includeViewParams=true";
inhandleNavigation()
, but I'll try useincludeViewParams
ath:link
– Week