0

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
  • how it doesn't work? What HTML is generated? Anything in the logs? Commented May 25, 2010 at 15:52

1 Answer 1

1

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()");
Sign up to request clarification or add additional context in comments.

2 Comments

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.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.