English 中文(简体)
f: ajaax 听众在动态添加 h: selectOneMenu 中失败
原标题:f:ajax listener fails within dynamically added h:selectOneMenu

I m dynamically adding a h:selectOneMenu to the page. But the listener method for f:ajax is not invoked for selectItems but it does work if h:selectOneMenu had been added to the page from the start (not dynamically added using update attribute). My code as follows:

(根据@Daniels建议更正)

    <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>  
最佳回答

h:command Button 没有 update 属性, 看起来像是介面和纯 JSF 的组合( update 属性来自 p:command Button )

向您的 命令按钮 添加 /code> 到您的 命令按钮 , 并使用 render 属性

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

将选择的ajax 修改为此

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

尝试将范围从 request 更改为 view

另一种方法是将 allow 的值设置在方法中, 像这样( 您也可以将它作为参数发送) 。

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


public void updateAllow(){
     allow = true;
}
问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...