In my JSF application I have two pages, list.jsf
and details.jsf
, and each page has its own controller with view scope. In list.jsf
I have a <h:commandLink>
that calls an action and pass a parameter:
<h:commandLink value="details" action="#{listBean.goToDetails}" >
<f:param name="id" value="#{listBean.object.pk}"/></h:commandLink>
This is the bean method:
@ManagedBean
@ViewScoped
public class ListBean {
public String goToDetails() {
// some code
return "details?faces-redirect=true";
}
}
I read the parameter in the second bean like this:
Map<String, String> params = FacesContext.getCurrentInstance()
.getExternalContext().getRequestParameterMap();
this.setIdParam(params.get("id"));
When I run this code, the parameter is not passed to the second bean instance.
However when I change navigation to forward
(without faces-redirect=true
), the parameter is passed and I can see the details in details.jsf
but the URL doesn't match with the current page.
So what I want to do is to use a "jsf implicit redirection" (not a forward) with POST parameters (f:param).