[英]jsf calling bean method from javascript using p:remoteCommand
我無法從我的JavaScript觸發bean方法。
myRemote()應該在xhtml中調用primefaces remoteCommand,這應該會觸發對bean中的test1()的調用,但這是永遠不會執行的。 為什么?
並且警報確實得到顯示,因此它在javascript中命中了addListener
我的JavaScript
function loadMarkers(m) {
for (var i = 0; i < m.length; i++) {
PF('w_gmap').addOverlay(m[i]);
//add listener for event clicking on marker
google.maps.event.addListener(m[i], 'click', function () {
myRemote(); //should be handled by p:remoteCommand
alert("HI 123");
});
}
}
的xhtml
<h:form styleClass="simpleformstyle" id="remoteForm">
<p:remoteCommand name="myRemote" actionListener="#{mapBean.test1}" process="@this"/>
</h:form>
從p:remoteCommand調用的bean方法
public void test1(){
System.out.println("HIIIIIIIIIIII");
}
因此,當我單擊一個標記時,click事件觸發器將被xhtml處理的myRemote()調用,然后應調用bean方法。 並顯示警報,因此它在javascript中命中了addListener
立即=“ true”解決了我的問題,一切都按預期進行
<h:form styleClass="simpleformstyle" id="remoteForm">
<p:remoteCommand name="myRemote" actionListener="#{mapBean.test1}" process="@this" immediate="true"/>
</h:form>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.