When I send parameters within the action method to another page I can not read them from second Class.
page1.xhtml:
....
<h:commandLink action="#{mbean1.gotoMessageDetail(msg)}" value="#{msg.caption}"/>
....
Managed bean1
@ManagedBean(name = "mbean1")
@RequestScoped
public class MBean1 {
....
public String gotoMessageDetail(Message msg) {
//do some work
retrun "page2.xhtml?param1=val1¶m2=val2";
}
}
At the second class MBean2 I try to take parameters with the following code block but I cant get the parameters I sent.
@ManagedBean(name = "mbean2")
@ViewScoped
public class MBean2{
...
HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
param1=Long.parseLong(request.getParameter("param1")==null ? "0" : request.getParameter("param1"));
param2=Long.parseLong(request.getParameter("param2")==null ? "0" : request.getParameter("param2"));
}
The param1 and param2 come null. How can I get param1 and param2 from mbean1's action method.