Search code examples
javajavascriptjsficefaces

Can I trigger an IceFaces action using JavaScript?


If I have a simple button:

   <ice:panelGroup> 
            <ice:commandButton value="foobar" 
            action="#{fileManager.openNoFlashVisiblePopup}" />
   </ice:panelGroup>

Is it possible to trigger the action openNoFlashVisiblePopup using just javascript? I know that there IceFaces has a JavaScript bridge but I don't know see a simple way to do just this.

i need to do this because I have a chunk of JavaScript that detects Flash and I need to show a IceFaces popup.


Solution

  • One way is to get the button element by ID and call its click() function.

    document.getElementById('clientId').click();
    

    You only need to give the form and button a fixed id so that you can use the generated HTML ID as clientId in Javascript code.