difference between action and actionListener

I would like to tell me which is the difference between anaction and anactionListener in the following example:

<h:form style="text-align:center">

<h:commandButton image="mountrushmore.jpg"

actionListener="#{rushmore.listen}"

action="#{rushmore.act}"/>

</h:form>

Which method of the rushmore bean is invoked first thelisten() or theact()? Based on the JSF lifecycle the action events are invoked in the Invoke Application Phase correct?So first we have the process of validation and then the action is invoked right?And then the listener?

Thanks in advance.

[756 byte] By [juanitaJa] at [2007-11-26 16:15:01]
# 1
Havd you tried it yourself? Just debug the action methods .. Add a logger or a sysout and see which one gets invoked first.Well, I've tried it earlier and I can say that the actionListener gets invoked first and then the action.
BalusCa at 2007-7-8 22:37:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Action = Executed in the invoke application phase. Runs a method in a bean that returns a String object. The String is used by the navigation system to determine which page to render next. The rules for this are set up in the faces-config.xml file, in the navigation-rule sections.

ActionListener = Executed in the invoke application phase. Is triggered when the action event occurs for the component the listener is attached too. This listener can perform miscellaneous actions required when the button is clicked, but does not return a String that affects the navigation.

What order do they get called? Try this out!

http://www.jsftutorials.net/faces-config/phaseTracker.html

It'll help you understand the JSF lifecycle. Which is VERY important, especially when those weird errors start occurring (or JSF seems to be ignoring your commands).

CowKing

IamCowKinga at 2007-7-8 22:37:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Ok thank you very much for your reply
juanitaJa at 2007-7-8 22:37:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...