1

私は奇妙な問題を抱えています。モーダル ダイアログに複数のフォームを配置しようとしていますが、フラグに基づいて一度に 1 つのフォームのみを表示し、ユーザー アクションに応じてあるフォームから別のフォームに動的に切り替えます。問題は、レンダリングされた属性をフォームに追加すると、Ajax イベントがバッキング Bean のサーバー側メソッドの呼び出しに失敗することです。

次のフォームとバッキング Bean は簡略化されたコピーですが、問題を示しています。基本的にh:form id="form2"からrender="#{requestScope.shouldRender}"を外してテキストフィールドに入力すれば想定通りに動作し、コンソールにテキストが表示されるようになります。render="#{requestScope.shouldRender}" を h:form id="form2" コンポーネントに追加すると、メソッドはまったく呼び出されません。

環境は: Primefaces 3.3 Spring 3.0 Websphere サーバー 7

以下は、 render 属性を使用したフォームの例です (正しく機能させるために削除してください)。

 <h:body>
        <h:form id="form1">
              <p:commandButton id="showButton" value="Show" update=":panel1">
                    <f:setPropertyActionListener value="#{true}"
                          target="#{requestScope.shouldRender}" />
              </p:commandButton>
        </h:form>

        <p:outputPanel id="panel1">
              <h:form id="form2" rendered="#{requestScope.shouldRender}">
                    <p:inputText id="fn" value="#{testBean.fn}">
                          <p:ajax event="keyup" listener="#{testBean.valueChangeListener}" />
                    </p:inputText>
              </h:form>
        </p:outputPanel>
  </h:body>

ここに小さなバッキング Bean があります。

    @Component
    @Scope("request")
    public class TestBean {
  private String fn;

  public void setFn(String fn) {
        this.fn = fn;
  }

  public String getFn() {
        return fn;
  }

  public void valueChangeListener() {
        System.out.println(fn);
  }

}

4

0 に答える 0