我有一个使用 primeFaces 的 JSF 站点。我无法使用 P:RemoreCommand 从我的 javascript 获取任何参数到我的 bean。这是我的代码:
xhtml:
<p:remoteCommand name="scaleLines" actionListener="#{mapBean2.scaleLines}" update="mapPanel"/>
然后稍后调用它:
map.on('viewreset', function(){
scaleLines({newZoom:'10'});
});
会话范围的 ManagedBean:
public void scaleLines(){
String newZoom = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("newZoom");
if(newZoom == null){
Logger.getAnonymousLogger().info("Zoom level is null");
}
else{
Integer newZoomInt = Integer.parseInt(newZoom);
this.mapzoomLevel = newZoomInt;
for(ZsyMap1Linetest line : allTestLines){
line.setWeight(((line.getWeight()*newZoomInt)/(6)));
}
}
}
这确实调用了该方法,但是当我附加调试器时,我可以看到 newZoom 始终为空,这意味着参数没有被传递。我已经阅读了其他帖子,但我不明白为什么它不会通过。我还尝试使用 JSF managedBean 作为支持 bean 和一个名为 bean 的 CDI,两者都有相同的结果。