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:
(Corrected after @Daniel’s suggestion)
<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:commandButtongot noupdateattribute, Looks like a mix of primefaces and pure JSF (updateattribute is fromp:commandButton)Add
f:ajaxto yourcommandButtonand userenderattributealso fix your selection ajax to this
and try change scope from
requesttoviewanother approach would be to set the value of
allowinside a method , like this (you can also send it as a parameter too)