In my app I have JSF page with some parameters
(url of example page: /pages/user.xhtml?id=123&userToShowId=2
)
On this page i have a commandButton
. After click it I want to redirect to the same page with all parameters. I know, that for this specified page I can do this manually this way:
public String redirect(){
//extCtx - ExternalContext
//ctx - FacesContext
Map<String,String> param = extCtx.getRequestParameterMap();
String currentURL = ctx.getViewRoot().getViewId();
return currentURL+"?userToShowId="+param.get("userToShowId")+"&id="+param.get("id");
}
But what to do when I want to get universal way to redirect from any page with any parameters?
If I have view parameters only at pages, without set it as a bean property:
<f:metadata>
<f:viewParam name="backurl"/>
<f:viewParam name="id"/>
</f:metadata>
not with value
:
<f:metadata>
<f:viewParam name="backurl" value=#{bean.id}/>
<f:viewParam name="id" value=#{bean.id}/>
</f:metadata>
can I use includeViewParams=true
to do my work?