views:

72

answers:

1

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.

+1  A: 

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.

BalusC
True, this would work I but temporarily created the button to open the popup - otherwise I don't need it... I could make the button not visible and trigger it this way but can I do this without a button? In addition I do not have control over the button's id since IceFaces generates it dynamically and uses it's unique id for the purposes of its mechanism.
Chris Tek
You can hide the button using CSS. No, you cannot invoke a JSF action without a JSF UICommand component. As to the ID, did you read the last sentence of my answer? Just give the form and button a fixed ID. Then JSF won't autogenerate it.
BalusC