我正在制作我的第一个 primefaces 移动网站,但我对视图有一种奇怪的行为
<pm:page>
<pm:view id="viewName">
<ui:include src="home.xhtml" />
</pm:view>
<pm:view id="otherView">
<ui:include src="viewWhereThereIsTheForm.xhtml" />
</pm:view>
</pm:page>
如果我在第二个视图(otherView)中使用commandButton(h:或p :),页面将重新加载并显示第一个视图(viewName),每次即使在有按钮的表单中有必需的元素
例子:
<h:form>
<h:inputText value="#{upload.something}" required="true" />
<h:commandButton value="Upload" action="#{upload.upload()}" />
//or
<p:commandButton value="Send" action="#{upload.trySomething()}" />
</h:form>
我尝试了一些解决方案,总是没有成功:
- 在支持 bean 方法中返回“pm:viewName”
- RequestContext.getCurrentInstance().execute("PrimeFaces.navigate('#viewName', {reverse : 'true'})");
- FacesContext.getCurrentInstance().getExternalContext().redirect("pageName.xhtml#viewName");
我唯一成功尝试过的是
<p:commandButton value="Send" action="#{upload.tryLatLon()}" oncomplete="PrimeFaces.navigate('#viewName', {reverse : 'true'})" />
但它不适用于 h:commandButton...
我怎么能停下来?!
任何帮助将不胜感激!
(我正在使用 PrimeFaces 3.5、PrimeFaces Mobile 0.9.4 和 JSF 2.2)