This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSF and the fly likes Executing two f:ajax in h:commandButton Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Executing two f:ajax in h:commandButton" Watch "Executing two f:ajax in h:commandButton" New topic
Author

Executing two f:ajax in h:commandButton

Lucas Murata
Greenhorn

Joined: Oct 13, 2010
Posts: 5
Hello,

I have a commandButton that when clicked must execute two ajax listener, i did code bellow:



This code is working fine. Strange that it's execute two times. Total of 4 calls to the method .

When I put only 1 f:ajax into h:commandButton, it's work fine, and calls just one time.

How to can call two f:ajax listener without repeat two times?
Cesar Loachamin
Ranch Hand

Joined: Dec 25, 2010
Posts: 90

Hi Lucas

Welcome to JavaRanch!!!

This is because you're binding two ajax listener to the same event in this case for the action event, one thing you could do is set another event for the first ajax listener, like this:
Try it, ti works.
But I suggest you, that you can use a single ajax call, put the logic of the method2 in method1 and render the two components like this:

Regards
Cesar

When a dream is ending because to come true - OCPJP 6,7. OCE JPA EE6. MCTS
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Executing two f:ajax in h:commandButton