How to trigger JSF render from jQuery

隐身守侯 提交于 2019-12-24 16:18:03

问题


Is it possible to trigger jsf <f:ajax render> inside an jQuery?

For example something like this:

/* if component Y changes
    trigger render event on component Y */

$("#source_compoment").bind("change", function(e) {
    $("#target_component").trigger("render");
});

Or with other words is there an equivalent for "f:ajax render" within jQuery?


回答1:


Yes , make a hidden button

<h:commandButton id="myHiddenButtonID" value="RenderSomething" style="display:none">
    <f:ajax render="target_component"></f:ajax>
</h:commandButton>

and click it from js

$("#myHiddenButtonID").click();

in your specific case it will look like this:

$("#source_compoment").bind("change", function(e) {
    $("#myHiddenButtonID").click();
});

b.t.w there is no "equivalent for "f:ajax render" within jQuery" you simple use jquery to click a hidden JSF button.


Edit

In case a third party JSF Library usage is relevant you can use the

Primefaces RemoteCommand - (use update attribute)

or

Richfaces/ a4j:jsFunction - (use reRender attribute)



来源:https://stackoverflow.com/questions/10698085/how-to-trigger-jsf-render-from-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!