Re: Struts 2.3.28.1 - Populate Java Property from Controller inside JavaScript

2016-08-29 Thread Lukasz Lenart
2016-08-27 0:08 GMT+02:00 Guilherme Bisconcini
:
> Hi all,
>
> First of all, greetings, from Brazil.
>
> I would like to populate this Java Script variable with name
> *flightPlanCoordinates
> *from a Action Controller.
>
> var flightPlanCoordinates = [
>
>
> {lat: -23.533592, lng: -46.742744},
>
> {lat: -23.533592, lng: -46.742744},
>
> {lat: -23.533870, lng: -46.742804},
>
> {lat: -23.533978, lng: -46.742890}
> ];
>
> Whats the best approach to do? I how can I use tag libs from Struts to
> mount this *flightPlanCoordinates ?*

I'd rather use a JSON endpoint instead of directly populating such
variable in a page.


Regards
-- 
Ɓukasz
+ 48 606 323 122 http://www.lenart.org.pl/

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: Struts 2.3.28.1 - Populate Java Property from Controller inside JavaScript

2016-08-29 Thread Christoph Nenning
> Hi all,
> 
> First of all, greetings, from Brazil.
> 
> I would like to populate this Java Script variable with name
> *flightPlanCoordinates
> *from a Action Controller.
> 
> var flightPlanCoordinates = [
> 
> 
> {lat: -23.533592, lng: -46.742744},
> 
> {lat: -23.533592, lng: -46.742744},
> 
> {lat: -23.533870, lng: -46.742804},
> 
> {lat: -23.533978, lng: -46.742890}
> ];
> 
> Whats the best approach to do? I how can I use tag libs from Struts to
> mount this *flightPlanCoordinates ?*
> 
> 
> Thanks in advance,
> 
> 
> Bisconcini


Hi,

it depends how your java classes look like.

If you have a class like this one:

public class Coordinates {
private double lat;
private double lng;
}


You could have a list in your acton:

public class SomeAction {
private List coordinates;

...

public List getCoordinates() {
return coordinates;
}

}


In a JSP you could access coordinates like this:

var flightPlanCoordinates = [

{lat: , 
lng: },

]


Be aware that this is just a very simple example. You should adjust it to 
your app.


Regards,
Christoph

This Email was scanned by Sophos Anti Virus