アクション メソッド内のパラメーターを別のページに送信すると、2 番目のクラスから読み取ることができません。
page1.xhtml:
....
<h:commandLink action="#{mbean1.gotoMessageDetail(msg)}" value="#{msg.caption}"/>
....
マネージド Bean1
@ManagedBean(name = "mbean1")
@RequestScoped
public class MBean1 {
....
public String gotoMessageDetail(Message msg) {
//do some work
retrun "page2.xhtml?param1=val1¶m2=val2";
}
}
2 番目のクラス MBean2 で、次のコード ブロックでパラメーターを取得しようとしましたが、送信したパラメーターを取得できません。
@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"));
}
param1 と param2 は null になります。mbean1 のアクション メソッドから param1 と param2 を取得するにはどうすればよいですか。