我无法从我的 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");
}
所以当我点击一个标记时,点击事件触发并且 myRemote() 应该被调用 xhtml 处理然后应该调用 bean 方法。并显示警报,因此它正在点击 javascript 中的 addListener