Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF difference between action, actionlistener, onClick [duplicate]

I am using JSF in my project. I am using a context menu from PrimeFaces. I see in p:menuItem we have action, actionListener, onclick methods. So my question is: When do I have to use action, actionListner, onclick and what is the order of execution?

like image 356
Lolly Avatar asked Jan 29 '14 17:01

Lolly


1 Answers

  • onclick will be executed first. It is used to call a javascript function.

  • actionListener is used when you want to have some ajax call to a
    method. That method should have the return type void, the method either take an ActionEvent as argument or no argument; it can also be used for a non-ajax call but then the page will be refreshed.

  • action is used to navigate to a different page; the method should have the return type String.

like image 88
Asif Avatar answered Oct 02 '22 13:10

Asif