Passing GMarkers Array to Tapestry

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Passing GMarkers Array to Tapestry

abangkis
Dear All,

I've got a question. I've created a page that has a Google Map
embedded on It. I want to store all of the markers that users click in
the map to a database. I've managed to collect the markers and store
it in a javascript array.

What i want to do is, when i submit a form on the page. The javascript
array is passed / accessible to the onSuccess() method so i can store
the value to the database, and vice versa.

Thanks a lot for your help

- abangkis -

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Passing GMarkers Array to Tapestry

ningdh-2
Hi,

I think you need append all the marker to the form action before form is submitted.
var url = form.action;
var markers = your marker string, format like 'a/b/c/d'
var index= url.indexOf("?");
 if (index< 0) {
  url = url + "/" + markers ;
 } else {
  url = url.substring(0,index) + "/" + markers + url.substring(index);
 }
form.action = url;

Then onSuccess handler would be like: onSuccess(String []markers).


DH

----- Original Message -----
From: "abangkis"
To: "Tapestry users" <[hidden email]>
Sent: Sunday, November 29, 2009 7:06 PM
Subject: Passing GMarkers Array to Tapestry


> Dear All,
>
> I've got a question. I've created a page that has a Google Map
> embedded on It. I want to store all of the markers that users click in
> the map to a database. I've managed to collect the markers and store
> it in a javascript array.
>
> What i want to do is, when i submit a form on the page. The javascript
> array is passed / accessible to the onSuccess() method so i can store
> the value to the database, and vice versa.
>
> Thanks a lot for your help
>
> - abangkis -
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Passing GMarkers Array to Tapestry

abangkis
Hi ningdh,

Thanks a lot for your answer, are suggesting that i manipulate the url
manually ?  Ok, let me try it.

BTW here's some snippet of the javascript code. i want to pass  the
gmarkers array so the onSuccess() method could access it.

<script type="text/javascript">
        var gmarkers = [];
        var map = null;
       
    function initialize() {
      if (GBrowserIsCompatible()) {
   
        map = new GMap2(document.getElementById("map_canvas"));
        data = new Array();
        map.setUIToDefault();

        GEvent.addListener(map, "click", function(overlay, latlng) {
                        var lat = latlng.lat();
  var lon = latlng.lng();
  var point = new GLatLng(lat, lon);
  var marker = new GMarker(point);
  gmarkers.push(marker);
                        map.addOverlay(marker);
                });
      }
    }
</script>

On Sun, Nov 29, 2009 at 7:43 PM, ningdh <[hidden email]> wrote:

> Hi,
>
> I think you need append all the marker to the form action before form is submitted.
> var url = form.action;
> var markers = your marker string, format like 'a/b/c/d'
> var index= url.indexOf("?");
>  if (index< 0) {
>  url = url + "/" + markers ;
>  } else {
>  url = url.substring(0,index) + "/" + markers + url.substring(index);
>  }
> form.action = url;
>
> Then onSuccess handler would be like: onSuccess(String []markers).
>
>
> DH
>
> ----- Original Message -----
> From: "abangkis"
> To: "Tapestry users" <[hidden email]>
> Sent: Sunday, November 29, 2009 7:06 PM
> Subject: Passing GMarkers Array to Tapestry
>
>
>> Dear All,
>>
>> I've got a question. I've created a page that has a Google Map
>> embedded on It. I want to store all of the markers that users click in
>> the map to a database. I've managed to collect the markers and store
>> it in a javascript array.
>>
>> What i want to do is, when i submit a form on the page. The javascript
>> array is passed / accessible to the onSuccess() method so i can store
>> the value to the database, and vice versa.
>>
>> Thanks a lot for your help
>>
>> - abangkis -
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Passing GMarkers Array to Tapestry

Thiago H de Paula Figueiredo
I guess the easier way would be a hidden TextField that will receive the  
value of the GMarkers via JavaScript. You'll have the values in a page or  
component field and have a parameterless onSuccess() method.

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Passing GMarkers Array to Tapestry

abangkis
Hi thiago, yes that would be a lot easier, thanks.

I think i can serialize the array to JSON and deserialized it on the
onSuccess method

Thanks

On Sun, Nov 29, 2009 at 8:56 PM, Thiago H. de Paula Figueiredo
<[hidden email]> wrote:

> I guess the easier way would be a hidden TextField that will receive the
> value of the GMarkers via JavaScript. You'll have the values in a page or
> component field and have a parameterless onSuccess() method.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and
> instructor
> Owner, software architect and developer, Ars Machina Tecnologia da
> Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]