tags:

views:

28

answers:

1

Hi,

Trying to do this programatically

<a4j:commandLink ... onclick="#{rich:component('modalPanelID')}.show()"/>

This doesn't work:

HtmlAjaxCommandLink commandLinkObject = new HtmlAjaxCommandLink();
...
commandLinkObject.setOnClick("#{rich:component('modalPanelID')}.show()");

Any idea why and how to make it work?

Thanx.

+1  A: 

Because the expression is never evaluated.

With the first approach when the page is rendered the #{rich:component...} is evaluated by Richfaces and something like the code below is rendered on the page:

document.getElementById('formID:modalPanelID').component.show();

Because you are doing this progammatically you are bypassing this rendering. I would suggest that you just use the rendered javascript from above.

commandLinkObject.setOnClick("document.getElementById('formID:modalPanelID').component.show()");
Damo
Thanks for opening my eyes on the evaluation thing (Hence the +1) but it still doesn't work. (do i need to use the formID:? I tried both with and without and still no go.
Ben
Got it.. You meant the id of the form. :-) thanks!
Ben
With JSF it all comes down to what gets rendered as HTML (etc). So if you examine what is rendered with Firebug then you'll find issues easily. In this case it would be checking that the ID created exists.
Damo