After calling the javascript function by clicking on logout p:remotecommand
is not executing.
This is my XHTML code:
<script type="text/javascript">
function logoutAccount() {
debugger;
var txt = "eeeeeeeeeeeeeee";
command([{name:'param',value:txt}]); //This is important
}
</script>
<a href="#" onclick="logoutAccount()"><i class="fa fa-sign-out fa-fw"></i> Logout</a>
<p:remoteCommand name="command" action="#{MyiaTaskBean.method}" />
This is my code in Java bean:
public void method() {
String value = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("param");
System.out.print("value is::::::::::::::::::::::"+value);
}
I tried to change action by action listener but it didn't work.
p:remoteCommand
needs to be inside form.
Below code works in my environmet (you haven't said what JSF/PF version you're using):
<script>
function logoutAccount() {
console.log('logoutAccount fired!');
var txt = 'some text';
command([{name:'param',value:txt}]);
}
</script>
<a href="#" onclick="logoutAccount()"><i class="fa fa-sign-out fa-fw"></i> Logout</a>
<h:form>
<p:remoteCommand name="command" action="#{testBean.method}" />
</h:form>
With your java code the result is:
value is::::::::::::::::::::::some text
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.