I have problem on a project with Gmap component of Primefaces 3.5 I'm using JSF2.0. I have this command Button that do filtering on the markers and most important updates mapForm
<h:form id="epsFilterForm">
<p:commandButton action="#{mapMB.filterProjects}" value="#{bundle['filter'] }" update=":mapForm" />
</h:form>
mapForm:
<h:form id="mapForm">
<p:gmap id="googleMap" center="48.849988,2.3805715" zoom="11" type="TERRAIN" fitBounds="false" model="#{mapMB.advancedModel}"
widgetVar="wmap" style="width:1000px;height:700px;display: inline-block;" >
<p:ajax event="overlaySelect" listener="#{mapMB.onMarkerSelect}" />
<p:gmapInfoWindow>
<p:outputPanel style="text-align:center;display:block;margin:auto:">
<p:panelGrid columns="2" styleClass="InfoTable" >
<p:outputLabel value="#{bundle['ep.operation.name'] }" />
<p:outputLabel value="#{mapMB.selectedEp.opName}" />
</p:panelGrid>
</p:outputPanel>
</p:gmapInfoWindow>
</p:gmap>
MapMB - scope - Session scope populateAdvancedModel()
public void populateAdvancedModel(List<EP> eps) {
advancedModel = new DefaultMapModel();
int count = 0;
Marker marker;
for (EP ep :eps) {
//advancedModel.addOverlay(new Marker(coord1, "Konyaalti", "konyaalti.png", "http://maps.google.com/mapfiles/ms/micons/blue-dot.png"));
System.out.println("Integer.toString(ep.getId()):"+Integer.toString(ep.getId()));
marker = new Marker(new LatLng( Double.parseDouble(ep.getLatitude()) , Double.parseDouble(ep.getLongitude())));
marker.setTitle( Integer.toString(count));
advancedModel.addOverlay(marker);
count++;
}
}
filterProjects()
public String filterProjects() {
//FilterMB filterMB = (FilterMB) JSFUtil.getManagedObject("filterMB");
eps = EPDAO.filterEPs(client, architect, realizationType, state, selectedCert);
populateAdvancedModel(eps);
return null;
}
onMarkerSelect()
public void onMarkerSelect(OverlaySelectEvent event) {
Marker marker = (Marker) event.getOverlay();
String markerTitle = marker.getTitle();
selectedEp = eps.get(Integer.parseInt(markerTitle));
}
When I load the page for first time everything is OK. Info (p:gmapInfoWindow ) window is loading and information for EP variable is there. But when I click the command button in epsFilterForm (that has some input fields that i haven't posted here) the map is updated and the filtered markers are there and they obviously have title when i hover on them, but overlaySelect event is not working in the same way. I thing that when page is loading for the first time there is some initial script that puts that behavior on the markers but when I refresh the map this initial script is not running again and that's is why when I click on the marker and overlaySelect event is fired I have null pointer Exception in onMarkerSelect() method (marker is null). IMPORTANT - this is working without a problem on local server but when I deploy it to google app engine it's working as i described above.