Selvin
Selvin

Reputation: 12493

why p:commandButton inside p:dialog does not fire actionListener?

<h:form prependId="false">

<p:dialog modal="true">

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

</p:dialog>

</h:form>

I had some other controls too inside the form. When the link is clicked that listener was not fired. What might be the problem? please help!

Upvotes: 4

Views: 15958

Answers (3)

ciroBorrelli
ciroBorrelli

Reputation: 19

You should use <h:commandLink action="... /> instead of <p:commandLink actionListener="... />

Example:

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

Upvotes: 1

Praveenkumar_V
Praveenkumar_V

Reputation: 1394

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 you

Upvotes: 0

BalusC
BalusC

Reputation: 1108722

You need to declare it as EL method expression, not as a plain string.

actionListener="#{Bean.listenerMethod}"

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

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

where ActionEvent is from the javax.faces package and not the java.awt one.

If that still doesn't work, then it's caused by something else. E.g. the form is nested, the rendered attribute evaluated false, etc. For an overview, see this answer.

Upvotes: 3

Related Questions