开发者

JSF - How to run javascript expression from code

开发者 https://www.devze.com 2022-12-31 19:15 出处:网络
Trying to do this programatically <a4j:commandLink ... onclick=\"#{rich:component(\'modalPanelID\')}.show()\"/>

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

精彩评论

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

关注公众号