In some cases, we might want to invoke an server side action via java script.
This can be done by <p:remoteCommand />.
with <p:remoteCommand />, we could assign a name to the remoteCommand component, then invoke the remoteCommand's action with the given name
In Addition, we might want to pass in some parameters to our server side action with the following syntax.
Request the passed in parameters' value
The idea here is to construct the <f:param />
=> <f:param name="myName1" value="myValue1" />
Done!!
This can be done by <p:remoteCommand />.
with <p:remoteCommand />, we could assign a name to the remoteCommand component, then invoke the remoteCommand's action with the given name
<p:remoteCommand name="rcTest"
action="#{myBean.someAction}"
update="any_component_id" />
<p:commandButton value="remote command test" onclick="rcTest();" />
In Addition, we might want to pass in some parameters to our server side action with the following syntax.
<p:commandButton value="remote command test"
onclick="rcTest(
[{name:'myName1',value:'myValue1'},{name:'myName2',value:myValue2}]);" />
Request the passed in parameters' value
public void someAction() {
FacesContext context = FacesContext.getCurrentInstance();
Map<String,String> params = context.getExternalContext().getRequestParameterMap();
String myName1 = params.get("myName1");
String myName2 = params.get("myName2");
}
The idea here is to construct the <f:param />
=> <f:param name="myName1" value="myValue1" />
Done!!
22.04.2014 2:17:51 com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
SEVERE: Error Rendering View[/test.xhtml]
javax.el.ELException: /resources/keremet/sendPoint.xhtml: Property 'method' not found on type com.keremet.SendPointBean
at com.sun.faces.facelets.compiler.AttributeInstruction.write(AttributeInstruction.java:94)
p.s.
DeleteI used code:
Hi,
Deletethere are some HTML reserved characters in your code.
use the HTML encoder to encode them first.
http://www.opinionatedgeek.com/DotNet/Tools/HTMLEncode/encode.aspx
stupid blog coudn't view the code I insert into comment!
ReplyDeletethanks a lot!
ReplyDeleteyou should work for primefaces docu team. They really need good people ;)
Nice tip. Thanks for that.
ReplyDelete