1

ページに動的に追加しh:selectOneMenuています。ただし、listenerメソッドf:ajaxは selectItems に対して呼び出されませんが、最初からページに追加されていた場合(属性h:selectOneMenuを使用して動的に追加されていない場合) は機能します。update次のように私のコード:

(@Daniel の提案により修正)

    <h:commandButton value="Watch">
          <f:ajax render="deptsSelBox"/>
          <f:setPropertyActionListener value="#{true}" target="#{listRetriever.allow}" />
    </h:commandButton>  

    <h:panelGroup id="deptsSelBox">
        <h:selectOneMenu id="deptsSel" rendered="#{listRetriever.allow}" value="#{listRetriever.reqId}">  
            <f:selectItems value="#{listRetriever.list}" />
            <f:ajax listener="#{listRetriever.retrieve()}" execute="deptsSel" />
        </h:selectOneMenu>
    </h:panelGroup>  
4

1 に答える 1

1

h:commandButton got no update attribute, Looks like a mix of primefaces and pure JSF (update attribute is from p:commandButton)

Add f:ajax to your commandButton and use render attribute

<h:commandButton value="Watch">
      <f:ajax render="deptsSelBox"/>
      <f:setPropertyActionListener value="#{true}" target="#{listRetriever.allow}" />
</h:commandButton>   

also fix your selection ajax to this

<f:ajax listener="#{listRetriever.retrieve}" update="deptsSel"/>

and try change scope from request to view

another approach would be to set the value of allow inside a method , like this (you can also send it as a parameter too)

<h:commandButton value="Watch" action="listRetriever.updateAllow">
      <f:ajax render="deptsSelBox"/>
</h:commandButton>  


public void updateAllow(){
     allow = true;
}
于 2012-05-24T06:04:42.670 に答える