admin管理员组文章数量:1424113
I define some java script function which will call the back-end functions using a4j:jsFunction.For example :
<a4j:jsFunction name="function1" action="#{Bean1.action1}" onplete="function2();"/>
<a4j:jsFunction name="function2" action="#{Bean1.action2}" onplete="SomeJSFunc2();"/>
Then in the a4j:mandButton , I set the onclick property to call my defined function like it:
<a4j:mandButton onclick="function1" onplete="SomeJSFunc3();">
When the a4j:mandButton is clicked , #{Bean1.action1} is run .After the #{Bean1.action1} returned , the onplete event of the (a4j:jsFunction name="function1") cannot invoke the "#{Bean1.action2}" .How can I solve this problem?
I define some java script function which will call the back-end functions using a4j:jsFunction.For example :
<a4j:jsFunction name="function1" action="#{Bean1.action1}" onplete="function2();"/>
<a4j:jsFunction name="function2" action="#{Bean1.action2}" onplete="SomeJSFunc2();"/>
Then in the a4j:mandButton , I set the onclick property to call my defined function like it:
<a4j:mandButton onclick="function1" onplete="SomeJSFunc3();">
When the a4j:mandButton is clicked , #{Bean1.action1} is run .After the #{Bean1.action1} returned , the onplete event of the (a4j:jsFunction name="function1") cannot invoke the "#{Bean1.action2}" .How can I solve this problem?
Share Improve this question asked May 24, 2010 at 10:38 Ken ChanKen Chan 90.8k26 gold badges154 silver badges184 bronze badges 1- did you check the javascript console (in firefox) – Bozho Commented May 24, 2010 at 13:16
1 Answer
Reset to default 3jsf page:
<a4j:mandButton
onplete="switchTab(1);"
action="#{backBean.actionSwitchTab4}"
value="#{res['button_forward']}c" styleClass="button" />
<a4j:jsFunction id="testFunc" name="switchTab"
action="#{backBean.actionSwitchTab}"
onplete="switchTab2(6);">
<a4j:actionparam name="tabIndex" assignTo="#{backBean.tabIndexTl}" />
</a4j:jsFunction>
<a4j:jsFunction id="testFunc2" name="switchTab2"
action="#{backBean.actionSwitchTab2}"
onplete="showConfirmPrompt();">
<a4j:actionparam name="tabIndex" assignTo="#{backBean.tabIndexTi}" />
</a4j:jsFunction>
<a4j:jsFunction id="testFunc3" name="switchTab3"
action="#{backBean.actionSwitchTab3}"
onplete="alert('this is the end');">
<a4j:actionparam name="tabIndex" assignTo="#{backBean.tabIndexTs}"/>
</a4j:jsFunction>
<script language="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, SETTER
private String tabIndexTs; // + GETTER, SETTER
private Long tabIndexTl; // + GETTER, SETTER
public Object actionSwitchTab() {
System.out.println(" >>>>> actionSwitchTab start; tabIndexTl: " + tabIndexTl);
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
System.out.println(" >>>>> actionSwitchTab end");
return null;
}
public Object actionSwitchTab2() {
System.out.println(" >>>>> actionSwitchTab2 start; tabIndexTi: " + tabIndexTi);
try {
Thread.sleep(500);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
System.out.println(" >>>>> actionSwitchTab2 end");
return null;
}
public Object actionSwitchTab3() {
System.out.println(" >>>>> actionSwitchTab3 start; tabIndexTs: " + tabIndexTs);
try {
Thread.sleep(3000);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
System.out.println(" >>>>> actionSwitchTab3 end");
return null;
}
public Object actionSwitchTab4() {
System.out.println(" >>>>> actionSwitchTab4");
return null;
}
本文标签: javascriptCalling another a4jjsFunction in an a4jjsFunction oncomplete eventStack Overflow
版权声明:本文标题:javascript - Calling another a4j:jsFunction in an a4j:jsFunction oncomplete event - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744660098a2618191.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论