我有尴尬的问题。 Primefaces的GMap组件按照我的预期工作,直到...在验证辅助bean上的数据后,我向组件返回一条消息。之后该地图对ajax的“pointSelect”事件没有反应。它可以移动,放大等,但我不能进入我负责添加标记的代码。这是我的代码:
Primefaces
<p:outputLabel for="add_marker" value="Punkt:" />
<p:outputPanel id="add_marker" style="text-align:center;">
<p:gmap id="add_gmap" widgetVar="addMap"
center="#{addSpotController.sampleSpot.latitude}, #{addSpotController.sampleSpot.longitude}" zoom="15"
model="#{addSpotController.model}" type="HYBRID" style="width:600px;height:400px" streetView="true">
<p:ajax event="pointSelect" listener="#{addSpotController.addMarker}"
update=":#{p:component('add_gmap')}, :#{p:component('add_msgs')},
:#{p:component('basicDT')},:#{p:component('mfDT')}" />
</p:gmap>
</p:outputPanel>
<p:commandButton id="add_confirm" value="Dodaj" actionListener="#{addSpotController.addSpot}"
update=":#{p:component('add_msgs')}, :#{p:component('addForm')}, :#{p:component('addInfoTitle')}, :#{p:component('add_gmap')}"
oncomplete="PF('addInfo').show()">
</p:commandButton>
BackingBean
public void addMarker(PointSelectEvent pse) {
FacesMessage message;
if (title == null || title.isEmpty()) {
message = new FacesMessage("Brak tytułu", "Najpierw wprowadź tytuł.");
} else {
if (!model.getMarkers().isEmpty()) {
model.getMarkers().clear();
}
Marker marker = new Marker(pse.getLatLng(), title);
model.addOverlay(marker);
LatLng latLng = marker.getLatlng();
sampleSpot.setLatitude(latLng.getLat());
sampleSpot.setLongitude(latLng.getLng());
message = new FacesMessage("Dodano punkt:", title);
}
FacesContext.getCurrentInstance().addMessage(null, message);
}
public void addSpot() {
if (isDataValid()) {
Marker marker = model.getMarkers().get(0);
savedID = spotService.addSpot(new UserBean(), marker, newSpotReceiverType, receiversList);
sampleSpot = spotService.getSampleSpot();
browseController.refreshSpotList();
modifyController.refreshSpotList();
clearForms();
setExportUrl();
} else {
for(String error: errors ) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Błędne dane", error);
FacesContext.getCurrentInstance().addMessage(null, message);
}
errors.clear();
}
}
为什么ajax会停止检索pointSelect事件?