I would like to call a JSF method inside my JavaScript code. For every time it executes this method in JavaScript within the function call another method that is inside JSF.
Does anyone have any idea how to do this?
I would like to call a JSF method inside my JavaScript code. For every time it executes this method in JavaScript within the function call another method that is inside JSF.
Does anyone have any idea how to do this?
You can use the PrimeFaces framework that contains a component for this, here's an example.
<h:form>
<p:remoteCommand name="rc" update="msgs" actionListener="#{remoteCommandView.execute}" />
<p:growl id="msgs" showDetail="true" />
<p:commandButton type="button" onclick="rc()" value="Execute" icon="ui-icon-refresh" />
</h:form>
In this component, <p:remoteCommand>
, the name
attribute determines a JavaScript function in which you can call to execute the JSF method defined in the actionListerner
attribute.
For more information and documentation on the component, see this link .