13 Replies Latest reply on Mar 10, 2009 11:35 AM by bronk horst

    <rich:gmap bug?

    bronk horst Newbie

      Hi,

      i`m using <rich:gmap to show some locations within my portlet (portal mode). Up to now my portlet had only one jsf-page which was shown when the user entered the portlet. The Gmap worked fine.

      What I`m doing now is calling the map-containing page from another jsf-page with the effect, that gmap is not shown. Ive only got a blank white screen with browser-output "reading maps.google.com" ... nothing happens. I already switched to the actual richfaces-libs. For testing, I also created a jsf-page that contains no other elements than the map... the porblem stays the same.

      Does anyone got the same problem or could help me findung a solution?
      Thanx a lot, here some parts of my code:



      <a4j:commandLink action="#{e2e.planningResults.move2Hotel}" rendered="#{appointment.hotelSegment}">
       <h:outputText value="#{appointment.modifiedType}"/>
      <a4j:actionparam name="selectedSegmentIndex" value="#{appointment.positionInItinerary}"
       assignTo="#{e2e.planningResults.selectedSegmentIndex}"/>
      </a4j:commandLink>
      




      <rich:gmap id="gm2" lat="#{e2e.hotel.MAP_LATTIDUDE_INITIAL}"
      lng="#{e2e.hotel.MAP_LONGTIDUDE_INITIAL}"
      zoom="#{e2e.hotel.MAP_ZOOM_INITIAL}" gmapVar="map2"
      gmapKey="#{e2e.hotel.googleKey}"
      style="#{e2e.hotel.MAP_STYLE}" oninit="initializePoints(); initializePointsAppointment()">
      </rich:gmap>
      


      jsvascripts:
      function createPoints(data) {
      for (var i = 0; data.length; i++) {
      var point = new GLatLng(data.latitude, data.longitude);
      map2.setZoom(11);
      map2.addOverlay(createMarkerWithIdentifier(point, data.anzeigeid, data.name, data.sterne, data.entfernungsDifferenz));
      }
      }
      
      function createMarkerWithIdentifier(point, id, name, sterne, entfernungsDifferenz) {
       var nummer = id;
       var ausgabestring = name +",<br>" + sterne + " Strene,<br>" + entfernungsDifferenz + " km zum Termin";
       var idIcon = new GIcon(baseIcon);
      idIcon.image = "http:/......./marker" + id + ".png";
      markerOptions = { icon:idIcon };
      var marker = new GMarker(point, markerOptions);
       GEvent.addListener(marker, "click", function() {
      marker.openInfoWindowHtml(ausgabestring);
      });
       return marker;
      }
      
      function createMarkerWithIdentifierAppointment(point, name, strasse) {
       var aString = name +",<br>" + strasse;
      var idIcon = new GIcon(baseIcon);
       idIcon.image = "http://server11117.isdg.de/images/mapicons/markert.png";
       markerOptions = { icon:idIcon };
       var marker = new GMarker(point, markerOptions);
       GEvent.addListener(marker, "click", function() {
       marker.openInfoWindowHtml(aString);
       });
       return marker;
      }
      
       //]]>
      </script>
      
      <a4j:jsFunction name="initializePoints" data="#{e2e.hotel.hotels_s}"
      oncomplete="createPoints(data)">
      </a4j:jsFunction>
      
      
      






        • 1. Re: <rich:gmap bug?
          Sergey Smirnov Master

          Do you mean you are re-rendering the part of the page where gmap is located?

          • 2. Re: <rich:gmap bug?
            bronk horst Newbie

            No. From page 1 im navigating to page 2 which contains the map. No page reload is performed. When I set the map containing page as initial page of my portlet, so thatit is shown when i enter the protlet, the map is shown. Only when i navigate to the page the problem occurs.

            • 3. Re: <rich:gmap bug?
              Ilya Shaikovsky Master

              So perform navigation from h:command*. You can't load the gmap via such ajax reRendering.

              • 4. Re: <rich:gmap bug?
                bronk horst Newbie

                Well, it works, my map is shown now. Furthermore i have another Problem. For navigation i cannot use Buttons, so i created an h:commandLink for navigation:

                [CODE]
                <h:commandLink action="#{e2e.planningResults.move2Hotel}" rendered="#{appointment.hotelSegment}" value="#{appointment.modifiedType}">

                <f:param name="selectedSegmentIndex" value="#{appointment.positionInItinerary}" assignTo="#{e2e.planningResults.selectedSegmentIndex}"/>
                </h:commandLink>
                {/CODE]

                This link does not start my method move2Hotel and does not set the parameter selectedSegmentIndex. What im doing wrong?

                thanx a lot

                • 5. Re: <rich:gmap bug?
                  Ilya Shaikovsky Master

                  1) f:param has no assignTo attribute.
                  2) appointment bean should be request scoped in order to use such conditional rendering without problems.

                  • 6. Re: <rich:gmap bug?
                    bronk horst Newbie

                    So, the Problem is that i need to set a beanproperty before moving to my mapcontaingng page. When I add a4f-support to my h:commandlink the parameter is set but the map is not rendered. When i do the following no method is been called and no parameter is set.

                    [CODE]
                    <h:commandLink action="#{e2e.planningResults.move2Hotel}" rendered="#{appointment.hotelSegment}" value="#{appointment.modifiedType}">
                    <f:param name="selectedSegmentIndex" value="#{appointment.positionInItinerary}"/>
                    </h:commandLink>
                    [/CODE]

                    When I use the following button my beanmethod is called but no parameter set

                    [CODE]
                    <h:commandButton value="#{appointment.modifiedType}" action="#{e2e.planningResults.move2Hotel}" style="width:170px;"
                    rendered="#{appointment.hotelSegment}">
                    <f:param name="selectedSegmentIndex" value="#{appointment.positionInItinerary}"/>
                    </h:commandButton>
                    [/CODE]

                    • 7. Re: <rich:gmap bug?
                      bronk horst Newbie

                      I forgot to mention that i have no managed beans. My masterBean stores several other beans as members.

                      • 8. Re: <rich:gmap bug?
                        Ilya Shaikovsky Master

                        you could get this parameter from request as usually with FacesContext.ExternalContext.RequestParametersMap.get() and assign from your action to any property you need.

                        • 9. Re: <rich:gmap bug?
                          bronk horst Newbie

                          Ok, this whould be a fine solution. But why does my commandLink not call the BeanMethod? (This Method is only called by the commandButton or by a4j-support in cimmandLink)

                          • 10. Re: <rich:gmap bug?
                            bronk horst Newbie

                            So, sorry i have to ask again...: i got a nice 0pointerexception when trying to get the parameter out of facescontext. What im doing is the following:

                            [CODE]
                            <h:commandButton value="#{appointment.modifiedType}" action="#{e2e.planningResults.move2Hotel}" style="width:170px;"
                            rendered="#{appointment.hotelSegment}">
                            <f:param name="selectedSegmentIndex" value="#{appointment.positionInItinerary}"/>

                            </h:commandButton>
                            [/CODE


                            [CODE]
                            ...
                            String xxx1 = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("selectedSegmentIndex").toString();
                            [/CODE]

                            • 11. Re: <rich:gmap bug?
                              Ilya Shaikovsky Master

                              ohm.. sorry.. yes.. Iforgot to mention.. We created a4j:htmlCommandLink and a4j:form especially for this problem. It will works and should be defined the same as common h: components but will works correct with conditional rendering using EL in rendered attribute. (standard ones has problems with hiddens which can't be added to form if wasn't rendered initially.) this info could be found in dev guide on these components or at livedemo pages.

                              • 12. Re: <rich:gmap bug?
                                Ilya Shaikovsky Master

                                1) read my previous comment which was posted before I read your next one.
                                2) f:param could be used only for command link in h:command*.

                                • 13. Re: <rich:gmap bug?
                                  bronk horst Newbie

                                  Well, let me give u a real big THAAAANX!
                                  Real nice working, again thanx a lot :)