File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Executing two f:ajax in h:commandButton

Lucas Murata

Joined: Oct 13, 2010
Posts: 5

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:


When a dream is ending because to come true - OCPJP 6,7. OCE JPA EE6. MCTS
I agree. Here's the link:
subject: Executing two f:ajax in h:commandButton
jQuery in Action, 3rd edition