Search code examples
jsf-2richfaces

How to stop event specified in a4j:support on certain conditions?


I have a4j:support inside a certain component. What i wanted to do is to disable the sending of ajax request on the component on certain conditions. How can i disable a4j:support/a4j:ajax not to fire the ajax request on that component. Let say for example a certain click on that component.

Thanks :)


Solution

  • Return false on the submit event of a4j:support:

    <a4j:support id="myField"
                 event="onblur" 
                 onsubmit="if(valid()==false){return false;}" 
                 oncomplete="complete();" 
                 actionListener="#{myBacking.myAction}" 
                 reRender="myOtherFields" />
    

    valid() returns true or false, if it returns true, you do nothing (don't return true).