How to run JSF rendering from jQuery

Is it possible to run jsf <f:ajax render> inside 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 in other words, is there an equivalent for "f: ajax render" inside jQuery?

+1
source share
1 answer

Yes, create a hidden button

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

and click on it with js

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

in your particular case, it will look like this:

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

btw there is no "equivalent for" f: ajax render "inside jQuery", you just use jquery to click the hidden JSF button.


Edit

In case the use of third-party JSF libraries matters, you can use

Primefaces RemoteCommand - (use update attribute)

or

Richfaces / a4j: jsFunction - (use reRender attribute)

+3
source

All Articles