There is an easy way to trigger a JavaScript action before and after calling <f:ajax listener> , for example. I would like to call window.alert("pre") before and window.alert("post") after onChange is called in the backup bean ACtrl :
<h:form> <h:inputText id="anId" value="#{cityCtrl.dbHost}"> <f:ajax event="change" listener="#{aCtrl.onChange}" execute="@all"/> </h:inputText> </h:form>
@ManagedBean public class ACtrlimplements Serializable { public void onChange(AjaxBehaviorEvent event) { System.out.println("something changed"); } }
Adding a few f:ajax elements doesn't seem to work (maybe it should be!), For example. in
<h:form> <h:inputText id="anId" value="#{cityCtrl.dbHost}"> <f:ajax event="change" listener="#{aCtrl.toggle}" execute="@all"/> <f:ajax event="change" listener="#{aCtrl.onChange}" execute="@all"/> <f:ajax event="change" listener="#{aCtrl.toggle}" execute="@all"/> </h:inputText> </h:form>
@ManagedBean public class ACtrlimplements Serializable { public void onChange(AjaxBehaviorEvent event) { System.out.println("something changed"); } public void toggle(AjaxBehaviorEvent event) { System.out.println("blah"); } }
only ACtrl.onChange is called.
source share