0
I would like to call a JSF method within my Javascript code. For every time he executes this method in Javascript within the function call another method that is within JSF.
Does anyone have any idea how to do that?
0
I would like to call a JSF method within my Javascript code. For every time he executes this method in Javascript within the function call another method that is within JSF.
Does anyone have any idea how to do that?
2
You can use the framework Primefaces which contains a component for this, follow 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 attribute name
determines a Javascript function in which you can call to execute the JSF method defined in the attribute actionListerner
.
For more information and documentation about the component see this link.
Browser other questions tagged javascript jsf
You are not signed in. Login or sign up in order to post.
Thanks for answering. but in this case there, I wanted to call this remote methodCommandView.execute within a javascrpt function. I don’t know if I understand.
– carleandro
Exactly. When you call
rc()
will be calling a Javascript function that will execute the method#{remoteCommandView.execute}
. Soon,rc()
can be called within a Javascript function as well. This you need?– Luídne
Yes, I did a test here, remoteCommand inside a form and it does not call the rc method();
– carleandro
You can show how you did it?
– Luídne
Sorry for the delay in answering, I tried a lot and I didn’t end up being sad :(. <h:form > <script src="code.js"></script> <p:remoteCommand name="rc" actionListener="#{gamesBean.addMissao()}" /> <p:commandButton type="button" onclick="test()" value="Execute" icon="ui-icon-refresh" /> </h:form> inside a code file.js Function test(){ rc(); }
– carleandro
Face discover the problem pq does not recognize the method. when it has <h:inputHidden inside the form it does not recognize the method of p:remoteCommand.
– carleandro
Um... good to know.
– Luídne
solve here. the problem is with inputhidden gets a list, so I send a list as string and convert to javascript. I don’t know if I understand it. but vlw for the help.
– carleandro