Calling Another A4j:jsfunction In An A4j:jsfunction Oncomplete Event
I define some java script function which will call the back-end functions using a4j:jsFunction.For example :
Solution 1:
jsf page:
<a4j:commandButtononcomplete="switchTab(1);"action="#{backBean.actionSwitchTab4}"value="#{res['button_forward']}c"styleClass="button" /><a4j:jsFunctionid="testFunc"name="switchTab"action="#{backBean.actionSwitchTab}"oncomplete="switchTab2(6);"><a4j:actionparamname="tabIndex"assignTo="#{backBean.tabIndexTl}" /></a4j:jsFunction><a4j:jsFunctionid="testFunc2"name="switchTab2"action="#{backBean.actionSwitchTab2}"oncomplete="showConfirmPrompt();"><a4j:actionparamname="tabIndex"assignTo="#{backBean.tabIndexTi}" /></a4j:jsFunction><a4j:jsFunctionid="testFunc3"name="switchTab3"action="#{backBean.actionSwitchTab3}"oncomplete="alert('this is the end');"><a4j:actionparamname="tabIndex"assignTo="#{backBean.tabIndexTs}"/></a4j:jsFunction><scriptlanguage="javascript"type="text/javascript"><!--
function showConfirmPrompt() {
if(confirm('Activate other a4j:jsFunction function')) {
switchTab3('test');
return true;
}
return false;
}
//--></script>
backbean(java):
private Integer tabIndexTi; // + GETTER, SETTERprivate String tabIndexTs; // + GETTER, SETTERprivate Long tabIndexTl; // + GETTER, SETTERpublic Object actionSwitchTab() {
System.out.println(" >>>>> actionSwitchTab start; tabIndexTl: " + tabIndexTl);
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
System.out.println(" >>>>> actionSwitchTab end");
returnnull;
}
public Object actionSwitchTab2() {
System.out.println(" >>>>> actionSwitchTab2 start; tabIndexTi: " + tabIndexTi);
try {
Thread.sleep(500);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
System.out.println(" >>>>> actionSwitchTab2 end");
returnnull;
}
public Object actionSwitchTab3() {
System.out.println(" >>>>> actionSwitchTab3 start; tabIndexTs: " + tabIndexTs);
try {
Thread.sleep(3000);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
System.out.println(" >>>>> actionSwitchTab3 end");
returnnull;
}
public Object actionSwitchTab4() {
System.out.println(" >>>>> actionSwitchTab4");
returnnull;
}
Post a Comment for "Calling Another A4j:jsfunction In An A4j:jsfunction Oncomplete Event"