3 Replies Latest reply on Mar 10, 2011 5:31 AM by Ilya Shaikovsky

    How to get the updated backing bean value to pass parameter for JS function

    Vishwanath Bannur Newbie

      Hi,

      I have created Gmap. And updating lng and lat value onclick of button in backing bean actionListener method.  Here I wanted to create marker and point on the updated lat and lng value by JS function. But I stuck to get the updated lat and lng value to pass to the JS function. Instead here the values are passing as old value. How to get the updated value to pass JS function (showExadel(lat,lng)) on click of button.  Here I have attached the code .xhtm and .java.

        • 1. How to get the updated backing bean value to pass parameter for JS function
          Ilya Shaikovsky Master

          you could use data attribute to serialize any object from server side and use later in oncomplete. like data=#{someBean} and oncomplete=alert('event.data.beanProperty')...

          • 2. How to get the updated backing bean value to pass parameter for JS function
            Vishwanath Bannur Newbie

            Hi ILya,

             

            Its working fine. Here the data is the selected object and on selected object it creates marker.

            However onload i need to create markers for all objects. I get to know that to use oninit attribute. But how can i pass the list of objects to JS.

            Can you please give me some hints?

             

            Here is the Code:

             

            <rich:gmap gmapVar="map" zoom="#{gmBean.zoom}"

                                          style="width:600px;height:600px" gmapKey="#{gmBean.gmapkey}"

                                          id="gmap" enableContinuousZoom="false" enableDoubleClickZoom="true"

                                          enableInfoWindow="true" oninit="loadMarkers('#{gmBean.point}');" locale="getDefaultLocale()" />

             

            <a4j:jsFunction name="showPlace" data="#{gmBean.selectedLocation}"

                                                              reRender=":zoom"

                                                              oncomplete="showExadel(data.lat,data.lng,data.zoom);return false;">

                                                              <a4j:actionparam name="id" assignTo="#{gmBean.currentId}"></a4j:actionparam>

                                                    </a4j:jsFunction>

             

            function showExadel(lat,lng,zoom) {

             

                                   var lat=lat;

                                          var lng=lng;

                                          var zoom=zoom;

                                          //alert(lat+"--"+lng);

                                              var point = new  GLatLng(lat, lng);

                                              map.setCenter(point);

                                              var marker = createMarker(point,'Go to the <a target="_blank" href="http://www.exadel.com">Exadle Web Site</a>');

                                                    map.setZoom(zoom);

                                                    map.addOverlay(marker);

                        

                         }

            • 3. Re: How to get the updated backing bean value to pass parameter for JS function
              Ilya Shaikovsky Master

              so pass List or objects using data in the same way. it shold be serialized to JS array as I believe.