我们是weblogic10.3.7中的JSF2。加载页面后JSF2 ajax调用
我们有要求在页面加载完成后自动触发ajax调用。
也许这可以从javascript document.ready函数触发。
有没有更好的方法?
感谢
我们是weblogic10.3.7中的JSF2。加载页面后JSF2 ajax调用
我们有要求在页面加载完成后自动触发ajax调用。
也许这可以从javascript document.ready函数触发。
有没有更好的方法?
感谢
看看PrimeFaces的RemoteCommand。你可以在你的document.ready
函数中调用这个RemoteCommand
来执行一些bean方法。
请尝试下面的代码,其中不包括任何外部库。
XHTML代码:
<script type="text/javascript">
var startCalls=false;
$(document).ready(function(){
clickButton();
startCalls=true;
})
function clickButton(){
document.getElementById('btn_test').click();
}
</script>
<h:commandButton id="btn_test" value="Test"
actionListener="#{testBean.increaseCount}"
style="display: none">
<f:ajax execute="btn_test" render="pnl_update_area"/>
</h:commandButton>
<h:panelGroup id="pnl_update_area">
This is called #{testBean.clickCount} times
<script type="text/javascript">
if(startCalls){
setTimeout('clickButton()',200);
}
</script>
</h:panelGroup>
JSF代码:
Integer clickCount=1;
public Integer getClickCount() {
return clickCount;
}
public void setClickCount(Integer clickCount) {
this.clickCount = clickCount;
}
public void increaseCount(ActionEvent event) {
clickCount++;
}
,您的触发火灾的一个或更多的时间? –
我的意思是你的触发器调用像池或一次调用按钮。 –
我有类似的需求,并通过使用以下内容来修复它:
要特别注意autoRun! – narko