0

我正在制作我的第一个 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)

4

2 回答 2

0

您应该将您的 primefaces 更新到 5.0 以获得更好的结果。我有同样的问题,我尝试了很多我无法得到任何解决方案的东西,将我的 primefaces 更新到最新版本解决了这个问题。

这是 pom.xml 文件中的一段代码,您可以在其中将您的 primefaces 从 3.5 更新到 5.0,只需更改版本标记中的数字即可。

         <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>5.0</version>
        </dependency>
于 2014-08-15T15:05:01.343 回答
0

您可能需要<pm:content><pm:view>.

我尝试使用<h:outputLink>如下代码所示在视图之间导航:

  <pm:page title="Mobile">
       <pm:view id="mainView">
        <pm:header title="Music Inventory" />
         <pm:content>
           <h:form id="mainForm">                   
              <h:outputLink value="#artist?transition=slide">Artists</h:outputLink>
          </h:form>
        </pm:content>
      </pm:view>
        <pm:view id="artist">
          <pm:header title="Artists">
            <h:outputLink value="#mainView">Go to Home</h:outputLink>
          </pm:header>
          <pm:content>
             <h:outputText value="Some detail of artists" />
          </pm:content>
        </pm:view>
    </pm:page>

Primefaces Mobile 网站中给出的一些示例无法正常工作,如展示中所示。

于 2014-04-23T14:34:09.733 回答