Skip to content Skip to sidebar Skip to footer

Is Any Way To Abort AjaxBehaviorEvent Listener Or Pass Additional Info To F:ajax Onevent?

I have created listener in my controller, something like that.. public class FooController { public void doSomething(AjaxBehaviorEvent evt) { closeDialogFlag = true;

Solution 1:

Here's a little trick for your specific problem:

  1. Create a <h:inputHidden id="closeDialogFlag" value="#{fooController.closeDialogFlag}"/> in the same <h:form> as your <h:commandButton ... />. Here, I suppose #{fooController.closeDialogFlag} is of type boolean.
  2. In your f:ajax:
    1. Render the component closeDialogFlag.
    2. Change your condition in the onevent to: function(data){ if(data.status === 'success' &amp;&amp; $('input#closeDialogFlag').val() === 'true') { $('#migrationEditDialogModal').modal('hide'); } }

You will have to change $('input#closeDialogFlag') to point to the correct ID (will depend on the parents' id).

This works because when data.status === 'success', the components are already rendered with their new values.


Post a Comment for "Is Any Way To Abort AjaxBehaviorEvent Listener Or Pass Additional Info To F:ajax Onevent?"