开发者

JSF - How to run javascript expression from code

Trying to do this programatically

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

This doesn't work:

HtmlAjaxCommandLink commandLinkObject = new HtmlAjaxCommand开发者_如何学JAVALink();
...
commandLinkObject.setOnClick("#{rich:component('modalPanelID')}.show()");

Any idea why and how to make it work?

Thanx.


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()");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜