我在页面page1.xhtml中有一个inputtext,我希望使用get方法将用户将输入到第二个页面page2.xhmtl中的值作为视图参数进行传递。我使用h:button并将其作为来自支持bean的结果值,但是当我导航到第二个页面时,该参数没有被传递。怎么了?在按下按钮之前,值是否未传递给支持bean,因此无法读取值?有没有别的办法呢?
page1.xhtml
h:inputText id="q" value="#{QBean.q}"></h:inputText>
<h:button value="Done" outcome="page2?q=#{indexBean.q}">
page2.xhtml
<f:metadata>
<f:viewParam name="q" value="#{QBean.q}"/>
</f:metadata>
QBean
private String q;
//setter
//getter
发布于 2012-03-21 00:04:42
你唯一的功能需求似乎是你想要一个GET表单而不是POST表单。在这种情况下,使用普通的HTML元素,而不是JSF组件。
<form action="page2.xhtml">
<input name="q" />
<input type="submit" value="Done" />
</form>
发布于 2012-03-21 03:15:01
您可以使用POST-REDIRECT-GET approach并使用commandButton:<h:commandButton value="Done" action="page2?faces-redirect=true&includeViewParams=true"/>
https://stackoverflow.com/questions/9790341
复制相似问题