-
1. Re: a4j:jsFunction sending a synchronous AJAX request and returning a value
healeyb Apr 25, 2012 12:55 PM (in response to awinizki)Hi, this example passes data to and back from the server. You need to use action= rather than actionListener
or the a4j:param isn't picked up (unless they've fixed it).
<h:commandButton value="click me" onclick="jsTest();"/>
<a4j:jsFunction name="jsTest"
oncomplete="alert(event.data)"
action="#{bean.jsTestAction}"
data="#{bean.jsTestData}">
<a4j:param name="p1" value="Fred" assignTo="#{bean.jsTestParam}"/>
</a4j:jsFunction>
public class Bean ... {
private String jsTestData;
private String jsTestParam;
public String jsTestAction() {
jsTestData = "Hello " + jsTestParam;
return null;
}
// getters & setters removed
}
The alert displays "Hello Fred".
Regards,
Brendan.