0

Using primefaces 6.2

I have this simple code:

<p:gmap center="50.848227, 4.356564" zoom="9" type="map" style="width:100%;height:600px" model="#{welcomePage.mapModel}">

        <p:ajax event="overlaySelect" listener="#{welcomePage.onMarkerSelect}" />

</p:gmap>

In header of html page:

<script src="http://maps.google.com/maps/api/js?key=*****" type="text/javascript"></script>

.

@WebPage
public class WelcomePage implements Serializable {

    private static final long serialVersionUID = -2444997383150958426L;

    @Getter
    @Setter
    MapModel mapModel;

    @PostConstruct
    public void init() {

        mapModel = new DefaultMapModel();

        ... add data to mapModel...

    }

    public void onMarkerSelect(OverlaySelectEvent event) {

        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "test", "test"));
    }
}

I dont know why but the method onMarkerSelect is never fired. Anybody can give me a hint? I never used Gmap primefaces component before.

onderbewustzijn
  • 935
  • 7
  • 32
  • What did you debug? https://stackoverflow.com/questions/2118656/commandbutton-commandlink-ajax-action-listener-method-not-invoked-or-input-value – Kukeltje Apr 17 '18 at 07:14
  • @Kukeltje everything that is debuggable... The gmap shows correctly added markers. But clicking on them doesn't fire the onMarkerSelect method. Putting inside the method breakpoints makes sure the event is not fired... Also tested on different browsers, with differen gmap options, but no luck. – onderbewustzijn Apr 17 '18 at 07:40
  • So you debugged in the browser if an actual ajax call was made during a click? (A lot happens between the click and calling of the method). You added a message component to check for errors, you ran your app in development mode, checked the server-side log files? etc? Please mention all these things next time. 'Method is not called' is very little information and does not show a lot of effort in finding the root cause – Kukeltje Apr 17 '18 at 07:43

1 Answers1

0

We were using default header and footer scripts, which comes from another team of our department. Apparently they use heavily jquery scripts and i noticed in the Safari webinfo windows there are multiple jquery versions used. Primefaces uses jquery plugins 1.12.1 and our team uses 1.11.0. Seems the browser accepts it all, JSF doesn't generate any error and AJAX request is fired, but the executed scripts, due to jquery version clashes, seems to silently run some code which is not compatible with the Primefaces javascript files. When removing header and footer scripts, everything works as expected!

Would be a nice feature of jQuery to detect this kind of clashes of course and give some kind of warning ^^. I asked the other team to investigate this issue. Case closed.

onderbewustzijn
  • 935
  • 7
  • 32
  • 1
    _"Would be a nice feature of the browser to detect this kind of clashes of course and give some kind of warning ^^."_ Very hard... Next to impossible. JQuery itself could include it... – Kukeltje Apr 20 '18 at 13:36