4
<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!

Selvin
  • 12,333
  • 17
  • 59
  • 80
  • 1
    Is this the exact code? There's a very obvious error, but I wouldn't like to play for Captain Obvious. – BalusC Mar 19 '11 at 06:04
  • Sorry I put commandLink instead instead of commandButton. is that the error BalusC? – Selvin Mar 19 '11 at 06:06
  • No, your `actionListener` isn't a method expression. It's a plain string. – BalusC Mar 19 '11 at 06:07
  • I ve previously used this notation(Bean.listenerMethod") to invoke the listeners. And it worked. Do you mean the correct notation is "Bean.listenerMethod()"? – Selvin Mar 19 '11 at 06:11

3 Answers3

3

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.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thank you Mr.Scholtz > My brain was dehydrated :) I was trying out every other thing. – Selvin Mar 19 '11 at 06:12
  • I tried like you said and put `#{Bean.listenerMethod}` But now also it don't fire the listener :( – Selvin Mar 19 '11 at 06:16
  • BalusC can I open another question, regarding this issue, with more detail. Can you please help? – Selvin Mar 19 '11 at 06:22
  • 1
    It has been some time ago with PrimeFaces and their documentation is not free anymore, but shouldn't the form go in the dialog? Also ensure that you aren't nesting forms in each other. – BalusC Mar 19 '11 at 06:23
  • I have checked the PrimeFaces 2.1 documentation and their showcase. Nowhere it is mentioned not to use forms inside p:dialog or p:confirmDialog. Anyway thank you for your hints :) – Selvin Mar 19 '11 at 09:04
  • Your clue was right BalusC. I was unknowingly nested a form within a form. Thats why the ActionListener was not fired. Now it is working. Thanks a lot.!!! – Selvin Mar 19 '11 at 09:58
  • @BalusC Can you please answer this question: http://stackoverflow.com/questions/26803879/adf-actionlistener-doesnt-fire-in-table-in-a-popup – GingerHead Nov 09 '14 at 17:10
1

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" />
0

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

Praveenkumar_V
  • 1,394
  • 2
  • 11
  • 19