Two Laptop Bag*
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
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
 
Consider Paul's rocket mass heater.
 
subject: Executing two f:ajax in h:commandButton
 
Similar Threads
Can we assign JSF Ajax Render attribute dynamically?
Send Ajax request to refresh dataTable
What is an efficient way to implement an entirely AJAX based web app using JSF2?
Ajax listener method is not fire for other(except first) component
How to rendered a <tr:commandButton (trinidad) via ajax