0
在我page1.xhtml如何將param從一頁傳遞到其他頁面?
<h:form>
<h:inputText value="#{page_one.name}" />
<h:commandButton action="#{page_one.onSubmit}" value="Submit" />
</h:form>
PageOneBean.class
@ManagedBean(name="page_one")
@RequestScoped
public class PageOneBean {
private String name;
public String onSubmit(){
return "/page2.xhtml";
}
}
page2.xhtml
<h:form>
<h:commandButton action="#{page_two.onSubmit}" value="Submit" />
</h:form>
PageTwoBean.class
@ManagedBean(name = "page_two")
@RequestScoped
public class PageTwoBean {
private String name;
public String onSubmit() {
System.out.println("name" + name);
return null;
}
}
如何CA當我點擊page_two.onSubmit按鈕時,我在pageTwoBean中獲得pageOneBean.name?
你需要在PageOneBean上使用另一個作用域或通過url傳遞參數,看看這個:http://balusc.blogspot.com/2006/06/communication-in-jsf.html –
在這裏檢查它 - http://stackoverflow.com/questions/3010732/jsf-pass-parameter-to-another-page –