Why p: commandButton inside p: dialog does not start actionListener?

<h:form prependId="false">

<p:dialog modal="true">

<p:commandLink ajax="true" value="ok" actionListener="Bean.listenerMethod"/>

</p:dialog>

</h:form>

I had other controls inside the form. When the link is clicked, the listener was not fired. What could be the problem? please, help!

+3
source share
3 answers

You need to declare it as an expression of an EL method, and not as a regular string.

actionListener="#{Bean.listenerMethod}"

Of course, there #{Bean}must be a valid managed bean with a managed name bean "Bean", which in turn contains the following method

public void listenerMethod(ActionEvent event) {
    // ...
}

where ActionEventfrom the package javax.faces, not java.awt.

If this still does not work, then it is caused by something else. For instance. the form is nested, the attribute is renderedevaluated false, etc. For a review, see this answer .

+2

<h:commandLink action="... /> <p:commandLink actionListener="... />

:

<h:commandLink id="elimina"
   action="#{listaBonificiModel.eliminaSelezionato()}"
   update="@(form)" oncomplete="PF('bonificoDialog').hide()"
   value ="Elimina" />
+1

Try

<h:form id="mainform">
    __________
    __________
    <p:dialog id="test" widgetVar="Testing">
       <h:form>
          <h:panelGrid columns="1">
             _________
             _________
          </h:panelGrid>
          <p:commandLink ajax="true" update="mainform" process="@all" value="ok" actionListener="#{Bean.listenerMethod}" oncomplete="Testing.hide()"/>
      </h:form>
    </p:dialog>
</h:form>

thank

0
source

All Articles