You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by sommeralex <al...@gmail.com> on 2012/09/21 13:40:11 UTC

updating a zone from javascript

Hello!

I have a javascript function, 

function onGetLatLng(gLatLng){

	if(gLatLng == null) {
		alert("Sorry, we couldn't find this address.");
		return false;
	}
	
	new Ajax.Request(urlGetGroupsOnLocation, { onSuccess: updatePage,
		parameters: 'lat='+gLatLng.lat() + '&lng=' + gLatLng.lng() + '&radius=' +
50000});
}

..which is calling urlGetGroupsOnLocation in my class:

	public Object onGetGroupsOnLocation(){
		System.out.println("onGetGroupsOnLocation");	

		if (request.getParameter("lat") != null && request.getParameter("lng") !=
null){
			Double lat = Double.parseDouble( request.getParameter("lat") );
			Double lng = Double.parseDouble( request.getParameter("lng") );
			Double radiusInMeters = Double.parseDouble(
request.getParameter("radius") ) / 2;
			
			Geometry location = GeometryService.getPolygon(new GeoPoint(lat, lng),
radiusInMeters.intValue());
			groups = groupService.getGroupsOnLocation(location);
			
			System.out.println("returnBody");				
			return zone.getBody(); 
		}
		System.out.println("null");
		return null;
	}

but, .. i dont know how to update the zone now with tapestry. zone.getBody
does not work. The only thing i managed was a hard approach within JS:

window.location.reload();


my full class:


package com.airwriting.frontend.pages.group;

import java.util.ArrayList;

import java.util.Date;

import java.util.List;


import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.Link;
import org.apache.tapestry5.annotations.Import;
import org.apache.tapestry5.annotations.InjectComponent;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.corelib.components.Zone;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.Request;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;

import se.unbound.tapestry.breadcrumbs.BreadCrumb;

import com.airwriting.configuration.Configuration;
import com.airwriting.domain.GeoPoint;
import com.airwriting.domain.Group;
import com.airwriting.service.GeometryService;
import com.airwriting.service.data.GroupService;
import com.vividsolutions.jts.geom.Geometry;

@Import(library = {
		"context:js/browselocalgroups.js" 
	})
@BreadCrumb(titleKey="group/ListLocalGroups")
public class ListLocalGroups {
	
	@Inject
	private GroupService groupService;
	@Inject
	private JavaScriptSupport jsSupport;
	@Inject
	private Request request;
	@Inject
	private ComponentResources componentResources;
	@Property
	private Geometry location;
	

	@Inject
	private Configuration configuration;

	@Property
	private String googleMapsKey;
	
	@Persist
	@Property
	private List<Group> groups;
		
	@InjectComponent
	private Zone zone;
	
	@Property
	private Group curGroup;
	
	@Persist	
	private Date lastUpdate;
	
	public void setupRender() {
		
		
		if (request.getServerName().endsWith(".net")){
			googleMapsKey = configuration.getString("googleMaps.key.net");
		}else if (request.getServerName().endsWith(".de")){
			googleMapsKey = configuration.getString("googleMaps.key.de");
		}else if (request.getServerName().endsWith(".at")){
			googleMapsKey = configuration.getString("googleMaps.key.at");
		}
		else {//.com
			googleMapsKey = configuration.getString("googleMaps.key");			
		}
		
		System.out.println("setupRender");
		
		if (groups == null || groups.size() == 0){
			
			System.out.println("createEventLink");
			Link linkGetGroupsOnLocation =
componentResources.createEventLink("getGroupsOnLocation");
			groups = new ArrayList<Group>();
			
			if (lastUpdate == null ){
				updatePage(linkGetGroupsOnLocation);
				 
			}else if (minutesDiff(lastUpdate, new Date()) > 1){
				updatePage(linkGetGroupsOnLocation);
				 
			}

		}else {
			
		}
	}

	private void updatePage(Link linkGetGroupsOnLocation) {
		jsSupport.addScript(
				"init('%s');", 
				linkGetGroupsOnLocation.toURI());
		lastUpdate = new Date();
	}
	
	
	
	public Object onGetGroupsOnLocation(){
		System.out.println("onGetGroupsOnLocation");	

		if (request.getParameter("lat") != null && request.getParameter("lng") !=
null){
			Double lat = Double.parseDouble( request.getParameter("lat") );
			Double lng = Double.parseDouble( request.getParameter("lng") );
			Double radiusInMeters = Double.parseDouble(
request.getParameter("radius") ) / 2;
			
			Geometry location = GeometryService.getPolygon(new GeoPoint(lat, lng),
radiusInMeters.intValue());
			groups = groupService.getGroupsOnLocation(location);
			
			System.out.println("returnBody");				
			return zone.getBody(); 
		}
		System.out.println("null");
		return null;
	}
	
	private static int minutesDiff(Date earlierDate, Date laterDate)
	{
	    if( earlierDate == null || laterDate == null ) return 0;

	    return (int)((laterDate.getTime()/60000) -
(earlierDate.getTime()/60000));
	}
	
}




--
View this message in context: http://tapestry.1045711.n5.nabble.com/updating-a-zone-from-javascript-tp5716428.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: updating a zone from javascript

Posted by sommeralex <al...@gmail.com>.
thx. now, everything is working as it should. ;-)

2012/9/21 Thiago H de Paula Figueiredo [via Tapestry] <
ml-node+s1045711n5716453h85@n5.nabble.com>

> On Fri, 21 Sep 2012 15:51:50 -0300, sommeralex
> <[hidden email] <http://user/SendEmail.jtp?type=node&node=5716453&i=0>>
> wrote:
>
> > i know that the zone itself does not trigger events. the zone itself is
> > just a HTML content.
> >
> > the question is, why zoneManager.update() is not enough. If i have zone
> > already defined in my java/tml class, why then is it not possible to
> > update
> > this zone just with zone.update from javascript? why do i have to put a
> > link within the update method?
> >
> > this is - from a didactic point of view - not understandable.
>
> AJAX in Tapestry works by using events and Zone doesn't trigger any. Zones
>
> are always supposed to be updated by Tapestry events.
>
> --
> Thiago H. de Paula Figueiredo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5716453&i=1>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5716453&i=2>
>
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://tapestry.1045711.n5.nabble.com/updating-a-zone-from-javascript-tp5716428p5716453.html
>  To unsubscribe from updating a zone from javascript, click here<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5716428&code=YWxleGFuZGVyLnNvbW1lckBnbWFpbC5jb218NTcxNjQyOHwxMDUzMzQxMzM4>
> .
> NAML<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://tapestry.1045711.n5.nabble.com/updating-a-zone-from-javascript-tp5716428p5716456.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

Re: updating a zone from javascript

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 21 Sep 2012 15:51:50 -0300, sommeralex  
<al...@gmail.com> wrote:

> i know that the zone itself does not trigger events. the zone itself is
> just a HTML content.
>
> the question is, why zoneManager.update() is not enough. If i have zone
> already defined in my java/tml class, why then is it not possible to  
> update
> this zone just with zone.update from javascript? why do i have to put a
> link within the update method?
>
> this is - from a didactic point of view - not understandable.

AJAX in Tapestry works by using events and Zone doesn't trigger any. Zones  
are always supposed to be updated by Tapestry events.

-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: updating a zone from javascript

Posted by sommeralex <al...@gmail.com>.
i know that the zone itself does not trigger events. the zone itself is
just a HTML content.

the question is, why zoneManager.update() is not enough. If i have zone
already defined in my java/tml class, why then is it not possible to update
this zone just with zone.update from javascript? why do i have to put a
link within the update method?

this is - from a didactic point of view - not understandable.

2012/9/21 Thiago H de Paula Figueiredo [via Tapestry] <
ml-node+s1045711n5716451h23@n5.nabble.com>

> On Fri, 21 Sep 2012 14:59:50 -0300, sommeralex
> <[hidden email] <http://user/SendEmail.jtp?type=node&node=5716451&i=0>>
> wrote:
>
> > function updatePage(response){
> >
> >
> >  var zoneManager = Tapestry.findZoneManagerForZone(zoneId);
> >
> > zoneManager.updateFromURL(urlGetGroupsOnLocation);
> >
> > }
> >
> >
> > but what i dont understand ist, why do i need an URL? why not
> > just zoneManager.update()?
> >
> >
> > I just want to tell tapestry to update that zone, no matter what url it
> > came from.
>
> The zone itself doesn't trigger events, it's just updated with content
> defined by some event handler method.
>
> --
> Thiago H. de Paula Figueiredo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5716451&i=1>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5716451&i=2>
>
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://tapestry.1045711.n5.nabble.com/updating-a-zone-from-javascript-tp5716428p5716451.html
>  To unsubscribe from updating a zone from javascript, click here<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5716428&code=YWxleGFuZGVyLnNvbW1lckBnbWFpbC5jb218NTcxNjQyOHwxMDUzMzQxMzM4>
> .
> NAML<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://tapestry.1045711.n5.nabble.com/updating-a-zone-from-javascript-tp5716428p5716452.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

Re: updating a zone from javascript

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 21 Sep 2012 14:59:50 -0300, sommeralex  
<al...@gmail.com> wrote:

> function updatePage(response){
>
>
>  var zoneManager = Tapestry.findZoneManagerForZone(zoneId);
>
> zoneManager.updateFromURL(urlGetGroupsOnLocation);
>
> }
>
>
> but what i dont understand ist, why do i need an URL? why not
> just zoneManager.update()?
>
>
> I just want to tell tapestry to update that zone, no matter what url it
> came from.

The zone itself doesn't trigger events, it's just updated with content  
defined by some event handler method.

-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: updating a zone from javascript

Posted by sommeralex <al...@gmail.com>.
this was the solution:


function updatePage(response){


 var zoneManager = Tapestry.findZoneManagerForZone(zoneId);

zoneManager.updateFromURL(urlGetGroupsOnLocation);

}


but what i dont understand ist, why do i need an URL? why not
just zoneManager.update()?


I just want to tell tapestry to update that zone, no matter what url it
came from.




--
View this message in context: http://tapestry.1045711.n5.nabble.com/updating-a-zone-from-javascript-tp5716428p5716450.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

Re: updating a zone from javascript

Posted by sommeralex <al...@gmail.com>.
Hi again and thx for the help.

Once again to summarize:

1. I have a java file with a ZONE. This zone is in my case just named
updateZone (Zone updateZone;)
2. I am adding some javascript, and giving the zoneID to my javascript file:

jsSupport.addScript(

"init('%s', '%s');",

linkGetGroupsOnLocation.toURI(), updateZone.getClientId());


3. my javascript init method is storing this zone id as a global variable:

function init(url, _zoneId){

alert ("zoneId: " + _zoneId);

 zoneId = _zoneId;

}


4.


my javascript function onGetLatLng is called if a location could be
retrieved (google maps api)


new Ajax.Request(urlGetGroupsOnLocation, { onSuccess: updatePage,

parameters: 'lat='+gLatLng.lat() + '&lng=' + gLatLng.lng() + '&radius=' +
50000});


onGetLatLng is calling a tapestry url to relaod some files for the
retrieved location. after that, a "onSuccess" javascript function is
called, which should update the zone with the new available data from the
server:


function updatePage(response){


 alert ("loading zone manager") ;

var zoneManager = Tapestry.findZoneManagerByZoneId(zoneId);

alert ("zone manager loaded") ;

  //window.location.reload();

}


but alert "zone manager loaded" is NOT called, - so there is some error..








2012/9/21 Ditso [via Tapestry] <ml...@n5.nabble.com>

> When you have to update the zone just use something like this. Notice
> the upper part is written in pseudo code.
>
> function update(){
> var zoneManager = Tapestry.findZoneManagerByZoneId( zoneId );
> var yourUrl = yourUrl;
>
> for(param : allParams){
>        yourUrl = addRequestParameter('param', param,
> listenerURIWithValue);
> }
>
> zoneManager.updateFromURL(listenerURIWithValue);
> }
>
> function addRequestParameter(name, value, url) {
>       if (url.indexOf('?') < 0) {
>             url += '?'
>       } else {
>             url += '&';
>       }
>       value = escape(value);
>       url += name + '=' + value;
>       return url;
> }
>
>
> On 21 September 2012 14:40, sommeralex <[hidden email]<http://user/SendEmail.jtp?type=node&node=5716431&i=0>>
> wrote:
>
> >
> > it is called, when a locatoin could be retrieved.
> >
> >
> > var urlGetGroupsOnLocation;
> >
> > var geocoder;
> >
> >
> >
> > function init(url){
> >
> > urlGetGroupsOnLocation = url;
> >
> >
> >  geocoder = new GClientGeocoder();
> >
> >  if (navigator.geolocation) {
> >
> > navigator.geolocation.getCurrentPosition(
> >
> > function(position){
> >
> > updateLocation(position.coords.latitude, position.coords.longitude);
> >
> > },
> >
> > function(msg){
> >
> > // error case: nothing todo because we have already initialized the map
> >
> > }
> >
> > );
> >
> > }else {
> >
> > alert("no location");
> >
> > }
> >
> >
> > }
> >
> >
> > function updateLocation(lat, lng){
> >
> > onGetLatLng(new GLatLng(lat,lng));
> >
> > }
> >
> >
> > function onGetLatLng(gLatLng){
> >
> >
> >  if(gLatLng == null) {
> >
> > alert("Sorry, we couldn't find this address.");
> >
> > return false;
> >
> > }
> >
> >  new Ajax.Request(urlGetGroupsOnLocation, { onSuccess: updatePage,
> >
> > parameters: 'lat='+gLatLng.lat() + '&lng=' + gLatLng.lng() + '&radius='
> +
> > 50000});
> >
> > }
> >
> >
> > function updatePage(response){
> >
> >
> >  window.location.reload();
> >
> >
> > }
> >
> >
> >
> >
> > 2012/9/21 Ditso [via Tapestry] <[hidden email]<http://user/SendEmail.jtp?type=node&node=5716431&i=1>>
>
> >
> > > Hi
> > >
> > > When is the function  onGetLatLng(gLatLng) called? When it's on a user
> > > event you can maybe have a look at the zone updater from jumpstart.
> > >
> > > http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/onevent
> > >
> > > kind regards
> > >
> > > On 21 September 2012 13:40, sommeralex <[hidden email]<
> http://user/SendEmail.jtp?type=node&node=5716429&i=0>>
> > > wrote:
> > >
> > > > Hello!
> > > >
> > > > I have a javascript function,
> > > >
> > > > function onGetLatLng(gLatLng){
> > > >
> > > >         if(gLatLng == null) {
> > > >                 alert("Sorry, we couldn't find this address.");
> > > >                 return false;
> > > >         }
> > > >
> > > >         new Ajax.Request(urlGetGroupsOnLocation, { onSuccess:
> > > updatePage,
> > > >                 parameters: 'lat='+gLatLng.lat() + '&lng=' +
> > > gLatLng.lng()
> > > > + '&radius=' +
> > > > 50000});
> > > > }
> > > >
> > > > ..which is calling urlGetGroupsOnLocation in my class:
> > > >
> > > >         public Object onGetGroupsOnLocation(){
> > > >                 System.out.println("onGetGroupsOnLocation");
> > > >
> > > >                 if (request.getParameter("lat") != null &&
> > > > request.getParameter("lng") !=
> > > > null){
> > > >                         Double lat = Double.parseDouble(
> > > > request.getParameter("lat") );
> > > >                         Double lng = Double.parseDouble(
> > > > request.getParameter("lng") );
> > > >                         Double radiusInMeters = Double.parseDouble(
> > > > request.getParameter("radius") ) / 2;
> > > >
> > > >                         Geometry location =
> > > GeometryService.getPolygon(new
> > > > GeoPoint(lat, lng),
> > > > radiusInMeters.intValue());
> > > >                         groups =
> > > > groupService.getGroupsOnLocation(location);
> > > >
> > > >                         System.out.println("returnBody");
> > > >                         return zone.getBody();
> > > >                 }
> > > >                 System.out.println("null");
> > > >                 return null;
> > > >         }
> > > >
> > > > but, .. i dont know how to update the zone now with tapestry.
> > > zone.getBody
> > > > does not work. The only thing i managed was a hard approach within
> JS:
> > > >
> > > > window.location.reload();
> > > >
> > > >
> > > > my full class:
> > > >
> > > >
> > > > package com.airwriting.frontend.pages.group;
> > > >
> > > > import java.util.ArrayList;
> > > >
> > > > import java.util.Date;
> > > >
> > > > import java.util.List;
> > > >
> > > >
> > > > import org.apache.tapestry5.ComponentResources;
> > > > import org.apache.tapestry5.Link;
> > > > import org.apache.tapestry5.annotations.Import;
> > > > import org.apache.tapestry5.annotations.InjectComponent;
> > > > import org.apache.tapestry5.annotations.Persist;
> > > > import org.apache.tapestry5.annotations.Property;
> > > > import org.apache.tapestry5.corelib.components.Zone;
> > > > import org.apache.tapestry5.ioc.annotations.Inject;
> > > > import org.apache.tapestry5.services.Request;
> > > > import org.apache.tapestry5.services.javascript.JavaScriptSupport;
> > > >
> > > > import se.unbound.tapestry.breadcrumbs.BreadCrumb;
> > > >
> > > > import com.airwriting.configuration.Configuration;
> > > > import com.airwriting.domain.GeoPoint;
> > > > import com.airwriting.domain.Group;
> > > > import com.airwriting.service.GeometryService;
> > > > import com.airwriting.service.data.GroupService;
> > > > import com.vividsolutions.jts.geom.Geometry;
> > > >
> > > > @Import(library = {
> > > >                 "context:js/browselocalgroups.js"
> > > >         })
> > > > @BreadCrumb(titleKey="group/ListLocalGroups")
> > > > public class ListLocalGroups {
> > > >
> > > >         @Inject
> > > >         private GroupService groupService;
> > > >         @Inject
> > > >         private JavaScriptSupport jsSupport;
> > > >         @Inject
> > > >         private Request request;
> > > >         @Inject
> > > >         private ComponentResources componentResources;
> > > >         @Property
> > > >         private Geometry location;
> > > >
> > > >
> > > >         @Inject
> > > >         private Configuration configuration;
> > > >
> > > >         @Property
> > > >         private String googleMapsKey;
> > > >
> > > >         @Persist
> > > >         @Property
> > > >         private List<Group> groups;
> > > >
> > > >         @InjectComponent
> > > >         private Zone zone;
> > > >
> > > >         @Property
> > > >         private Group curGroup;
> > > >
> > > >         @Persist
> > > >         private Date lastUpdate;
> > > >
> > > >         public void setupRender() {
> > > >
> > > >
> > > >                 if (request.getServerName().endsWith(".net")){
> > > >                         googleMapsKey = configuration.getString("
> > > > googleMaps.key.net");
> > > >                 }else if (request.getServerName().endsWith(".de")){
> > > >                         googleMapsKey = configuration.getString("
> > > > googleMaps.key.de");
> > > >                 }else if (request.getServerName().endsWith(".at")){
> > > >                         googleMapsKey = configuration.getString("
> > > > googleMaps.key.at");
> > > >                 }
> > > >                 else {//.com
> > > >                         googleMapsKey =
> > > > configuration.getString("googleMaps.key");
> > > >                 }
> > > >
> > > >                 System.out.println("setupRender");
> > > >
> > > >                 if (groups == null || groups.size() == 0){
> > > >
> > > >                         System.out.println("createEventLink");
> > > >                         Link linkGetGroupsOnLocation =
> > > > componentResources.createEventLink("getGroupsOnLocation");
> > > >                         groups = new ArrayList<Group>();
> > > >
> > > >                         if (lastUpdate == null ){
> > > >                                 updatePage(linkGetGroupsOnLocation);
> > > >
> > > >                         }else if (minutesDiff(lastUpdate, new
> Date()) >
> > > 1){
> > > >                                 updatePage(linkGetGroupsOnLocation);
> > > >
> > > >                         }
> > > >
> > > >                 }else {
> > > >
> > > >                 }
> > > >         }
> > > >
> > > >         private void updatePage(Link linkGetGroupsOnLocation) {
> > > >                 jsSupport.addScript(
> > > >                                 "init('%s');",
> > > >                                 linkGetGroupsOnLocation.toURI());
> > > >                 lastUpdate = new Date();
> > > >         }
> > > >
> > > >
> > > >
> > > >         public Object onGetGroupsOnLocation(){
> > > >                 System.out.println("onGetGroupsOnLocation");
> > > >
> > > >                 if (request.getParameter("lat") != null &&
> > > > request.getParameter("lng") !=
> > > > null){
> > > >                         Double lat = Double.parseDouble(
> > > > request.getParameter("lat") );
> > > >                         Double lng = Double.parseDouble(
> > > > request.getParameter("lng") );
> > > >                         Double radiusInMeters = Double.parseDouble(
> > > > request.getParameter("radius") ) / 2;
> > > >
> > > >                         Geometry location =
> > > GeometryService.getPolygon(new
> > > > GeoPoint(lat, lng),
> > > > radiusInMeters.intValue());
> > > >                         groups =
> > > > groupService.getGroupsOnLocation(location);
> > > >
> > > >                         System.out.println("returnBody");
> > > >                         return zone.getBody();
> > > >                 }
> > > >                 System.out.println("null");
> > > >                 return null;
> > > >         }
> > > >
> > > >         private static int minutesDiff(Date earlierDate, Date
> laterDate)
> > > >         {
> > > >             if( earlierDate == null || laterDate == null ) return 0;
> > > >
> > > >             return (int)((laterDate.getTime()/60000) -
> > > > (earlierDate.getTime()/60000));
> > > >         }
> > > >
> > > > }
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > View this message in context:
> > > >
> > >
> http://tapestry.1045711.n5.nabble.com/updating-a-zone-from-javascript-tp5716428.html
> > > > Sent from the Tapestry - User mailing list archive at Nabble.com.
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: [hidden email]<
> http://user/SendEmail.jtp?type=node&node=5716429&i=1>
> > > > For additional commands, e-mail: [hidden email]<
> http://user/SendEmail.jtp?type=node&node=5716429&i=2>
> > > >
> > > >
> > >
> > >
> > > ------------------------------
> > >  If you reply to this email, your message will be added to the
> discussion
> > > below:
> > >
> > >
>
> > > .
> > > NAML<
> http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
> > >
> >
> >
> >
> >
> > --
> > View this message in context:
> http://tapestry.1045711.n5.nabble.com/updating-a-zone-from-javascript-tp5716428p5716430.html
>
> > Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5716431&i=2>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5716431&i=3>
>
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://tapestry.1045711.n5.nabble.com/updating-a-zone-from-javascript-tp5716428p5716431.html
>  To unsubscribe from updating a zone from javascript, click here<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5716428&code=YWxleGFuZGVyLnNvbW1lckBnbWFpbC5jb218NTcxNjQyOHwxMDUzMzQxMzM4>
> .
> NAML<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://tapestry.1045711.n5.nabble.com/updating-a-zone-from-javascript-tp5716428p5716449.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

Re: updating a zone from javascript

Posted by Dieter Sauvillers <di...@gmail.com>.
When you have to update the zone just use something like this. Notice
the upper part is written in pseudo code.

function update(){
var zoneManager = Tapestry.findZoneManagerByZoneId( zoneId );
var yourUrl = yourUrl;

for(param : allParams){
       yourUrl = addRequestParameter('param', param, listenerURIWithValue);
}

zoneManager.updateFromURL(listenerURIWithValue);
}

function addRequestParameter(name, value, url) {
      if (url.indexOf('?') < 0) {
            url += '?'
      } else {
            url += '&';
      }
      value = escape(value);
      url += name + '=' + value;
      return url;
}


On 21 September 2012 14:40, sommeralex <al...@gmail.com> wrote:
>
> it is called, when a locatoin could be retrieved.
>
>
> var urlGetGroupsOnLocation;
>
> var geocoder;
>
>
>
> function init(url){
>
> urlGetGroupsOnLocation = url;
>
>
>  geocoder = new GClientGeocoder();
>
>  if (navigator.geolocation) {
>
> navigator.geolocation.getCurrentPosition(
>
> function(position){
>
> updateLocation(position.coords.latitude, position.coords.longitude);
>
> },
>
> function(msg){
>
> // error case: nothing todo because we have already initialized the map
>
> }
>
> );
>
> }else {
>
> alert("no location");
>
> }
>
>
> }
>
>
> function updateLocation(lat, lng){
>
> onGetLatLng(new GLatLng(lat,lng));
>
> }
>
>
> function onGetLatLng(gLatLng){
>
>
>  if(gLatLng == null) {
>
> alert("Sorry, we couldn't find this address.");
>
> return false;
>
> }
>
>  new Ajax.Request(urlGetGroupsOnLocation, { onSuccess: updatePage,
>
> parameters: 'lat='+gLatLng.lat() + '&lng=' + gLatLng.lng() + '&radius=' +
> 50000});
>
> }
>
>
> function updatePage(response){
>
>
>  window.location.reload();
>
>
> }
>
>
>
>
> 2012/9/21 Ditso [via Tapestry] <ml...@n5.nabble.com>
>
> > Hi
> >
> > When is the function  onGetLatLng(gLatLng) called? When it's on a user
> > event you can maybe have a look at the zone updater from jumpstart.
> >
> > http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/onevent
> >
> > kind regards
> >
> > On 21 September 2012 13:40, sommeralex <[hidden email]<http://user/SendEmail.jtp?type=node&node=5716429&i=0>>
> > wrote:
> >
> > > Hello!
> > >
> > > I have a javascript function,
> > >
> > > function onGetLatLng(gLatLng){
> > >
> > >         if(gLatLng == null) {
> > >                 alert("Sorry, we couldn't find this address.");
> > >                 return false;
> > >         }
> > >
> > >         new Ajax.Request(urlGetGroupsOnLocation, { onSuccess:
> > updatePage,
> > >                 parameters: 'lat='+gLatLng.lat() + '&lng=' +
> > gLatLng.lng()
> > > + '&radius=' +
> > > 50000});
> > > }
> > >
> > > ..which is calling urlGetGroupsOnLocation in my class:
> > >
> > >         public Object onGetGroupsOnLocation(){
> > >                 System.out.println("onGetGroupsOnLocation");
> > >
> > >                 if (request.getParameter("lat") != null &&
> > > request.getParameter("lng") !=
> > > null){
> > >                         Double lat = Double.parseDouble(
> > > request.getParameter("lat") );
> > >                         Double lng = Double.parseDouble(
> > > request.getParameter("lng") );
> > >                         Double radiusInMeters = Double.parseDouble(
> > > request.getParameter("radius") ) / 2;
> > >
> > >                         Geometry location =
> > GeometryService.getPolygon(new
> > > GeoPoint(lat, lng),
> > > radiusInMeters.intValue());
> > >                         groups =
> > > groupService.getGroupsOnLocation(location);
> > >
> > >                         System.out.println("returnBody");
> > >                         return zone.getBody();
> > >                 }
> > >                 System.out.println("null");
> > >                 return null;
> > >         }
> > >
> > > but, .. i dont know how to update the zone now with tapestry.
> > zone.getBody
> > > does not work. The only thing i managed was a hard approach within JS:
> > >
> > > window.location.reload();
> > >
> > >
> > > my full class:
> > >
> > >
> > > package com.airwriting.frontend.pages.group;
> > >
> > > import java.util.ArrayList;
> > >
> > > import java.util.Date;
> > >
> > > import java.util.List;
> > >
> > >
> > > import org.apache.tapestry5.ComponentResources;
> > > import org.apache.tapestry5.Link;
> > > import org.apache.tapestry5.annotations.Import;
> > > import org.apache.tapestry5.annotations.InjectComponent;
> > > import org.apache.tapestry5.annotations.Persist;
> > > import org.apache.tapestry5.annotations.Property;
> > > import org.apache.tapestry5.corelib.components.Zone;
> > > import org.apache.tapestry5.ioc.annotations.Inject;
> > > import org.apache.tapestry5.services.Request;
> > > import org.apache.tapestry5.services.javascript.JavaScriptSupport;
> > >
> > > import se.unbound.tapestry.breadcrumbs.BreadCrumb;
> > >
> > > import com.airwriting.configuration.Configuration;
> > > import com.airwriting.domain.GeoPoint;
> > > import com.airwriting.domain.Group;
> > > import com.airwriting.service.GeometryService;
> > > import com.airwriting.service.data.GroupService;
> > > import com.vividsolutions.jts.geom.Geometry;
> > >
> > > @Import(library = {
> > >                 "context:js/browselocalgroups.js"
> > >         })
> > > @BreadCrumb(titleKey="group/ListLocalGroups")
> > > public class ListLocalGroups {
> > >
> > >         @Inject
> > >         private GroupService groupService;
> > >         @Inject
> > >         private JavaScriptSupport jsSupport;
> > >         @Inject
> > >         private Request request;
> > >         @Inject
> > >         private ComponentResources componentResources;
> > >         @Property
> > >         private Geometry location;
> > >
> > >
> > >         @Inject
> > >         private Configuration configuration;
> > >
> > >         @Property
> > >         private String googleMapsKey;
> > >
> > >         @Persist
> > >         @Property
> > >         private List<Group> groups;
> > >
> > >         @InjectComponent
> > >         private Zone zone;
> > >
> > >         @Property
> > >         private Group curGroup;
> > >
> > >         @Persist
> > >         private Date lastUpdate;
> > >
> > >         public void setupRender() {
> > >
> > >
> > >                 if (request.getServerName().endsWith(".net")){
> > >                         googleMapsKey = configuration.getString("
> > > googleMaps.key.net");
> > >                 }else if (request.getServerName().endsWith(".de")){
> > >                         googleMapsKey = configuration.getString("
> > > googleMaps.key.de");
> > >                 }else if (request.getServerName().endsWith(".at")){
> > >                         googleMapsKey = configuration.getString("
> > > googleMaps.key.at");
> > >                 }
> > >                 else {//.com
> > >                         googleMapsKey =
> > > configuration.getString("googleMaps.key");
> > >                 }
> > >
> > >                 System.out.println("setupRender");
> > >
> > >                 if (groups == null || groups.size() == 0){
> > >
> > >                         System.out.println("createEventLink");
> > >                         Link linkGetGroupsOnLocation =
> > > componentResources.createEventLink("getGroupsOnLocation");
> > >                         groups = new ArrayList<Group>();
> > >
> > >                         if (lastUpdate == null ){
> > >                                 updatePage(linkGetGroupsOnLocation);
> > >
> > >                         }else if (minutesDiff(lastUpdate, new Date()) >
> > 1){
> > >                                 updatePage(linkGetGroupsOnLocation);
> > >
> > >                         }
> > >
> > >                 }else {
> > >
> > >                 }
> > >         }
> > >
> > >         private void updatePage(Link linkGetGroupsOnLocation) {
> > >                 jsSupport.addScript(
> > >                                 "init('%s');",
> > >                                 linkGetGroupsOnLocation.toURI());
> > >                 lastUpdate = new Date();
> > >         }
> > >
> > >
> > >
> > >         public Object onGetGroupsOnLocation(){
> > >                 System.out.println("onGetGroupsOnLocation");
> > >
> > >                 if (request.getParameter("lat") != null &&
> > > request.getParameter("lng") !=
> > > null){
> > >                         Double lat = Double.parseDouble(
> > > request.getParameter("lat") );
> > >                         Double lng = Double.parseDouble(
> > > request.getParameter("lng") );
> > >                         Double radiusInMeters = Double.parseDouble(
> > > request.getParameter("radius") ) / 2;
> > >
> > >                         Geometry location =
> > GeometryService.getPolygon(new
> > > GeoPoint(lat, lng),
> > > radiusInMeters.intValue());
> > >                         groups =
> > > groupService.getGroupsOnLocation(location);
> > >
> > >                         System.out.println("returnBody");
> > >                         return zone.getBody();
> > >                 }
> > >                 System.out.println("null");
> > >                 return null;
> > >         }
> > >
> > >         private static int minutesDiff(Date earlierDate, Date laterDate)
> > >         {
> > >             if( earlierDate == null || laterDate == null ) return 0;
> > >
> > >             return (int)((laterDate.getTime()/60000) -
> > > (earlierDate.getTime()/60000));
> > >         }
> > >
> > > }
> > >
> > >
> > >
> > >
> > > --
> > > View this message in context:
> > >
> > http://tapestry.1045711.n5.nabble.com/updating-a-zone-from-javascript-tp5716428.html
> > > Sent from the Tapestry - User mailing list archive at Nabble.com.
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5716429&i=1>
> > > For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5716429&i=2>
> > >
> > >
> >
> >
> > ------------------------------
> >  If you reply to this email, your message will be added to the discussion
> > below:
> >
> > http://tapestry.1045711.n5.nabble.com/updating-a-zone-from-javascript-tp5716428p5716429.html
> >  To unsubscribe from updating a zone from javascript, click here<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5716428&code=YWxleGFuZGVyLnNvbW1lckBnbWFpbC5jb218NTcxNjQyOHwxMDUzMzQxMzM4>
> > .
> > NAML<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
> >
>
>
>
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/updating-a-zone-from-javascript-tp5716428p5716430.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: updating a zone from javascript

Posted by sommeralex <al...@gmail.com>.
it is called, when a locatoin could be retrieved.


var urlGetGroupsOnLocation;

var geocoder;



function init(url){

urlGetGroupsOnLocation = url;


 geocoder = new GClientGeocoder();

 if (navigator.geolocation) {

navigator.geolocation.getCurrentPosition(

function(position){

updateLocation(position.coords.latitude, position.coords.longitude);

},

function(msg){

// error case: nothing todo because we have already initialized the map

}

);

}else {

alert("no location");

}


}


function updateLocation(lat, lng){

onGetLatLng(new GLatLng(lat,lng));

}


function onGetLatLng(gLatLng){


 if(gLatLng == null) {

alert("Sorry, we couldn't find this address.");

return false;

}

 new Ajax.Request(urlGetGroupsOnLocation, { onSuccess: updatePage,

parameters: 'lat='+gLatLng.lat() + '&lng=' + gLatLng.lng() + '&radius=' +
50000});

}


function updatePage(response){


 window.location.reload();


}




2012/9/21 Ditso [via Tapestry] <ml...@n5.nabble.com>

> Hi
>
> When is the function  onGetLatLng(gLatLng) called? When it's on a user
> event you can maybe have a look at the zone updater from jumpstart.
>
> http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/onevent
>
> kind regards
>
> On 21 September 2012 13:40, sommeralex <[hidden email]<http://user/SendEmail.jtp?type=node&node=5716429&i=0>>
> wrote:
>
> > Hello!
> >
> > I have a javascript function,
> >
> > function onGetLatLng(gLatLng){
> >
> >         if(gLatLng == null) {
> >                 alert("Sorry, we couldn't find this address.");
> >                 return false;
> >         }
> >
> >         new Ajax.Request(urlGetGroupsOnLocation, { onSuccess:
> updatePage,
> >                 parameters: 'lat='+gLatLng.lat() + '&lng=' +
> gLatLng.lng()
> > + '&radius=' +
> > 50000});
> > }
> >
> > ..which is calling urlGetGroupsOnLocation in my class:
> >
> >         public Object onGetGroupsOnLocation(){
> >                 System.out.println("onGetGroupsOnLocation");
> >
> >                 if (request.getParameter("lat") != null &&
> > request.getParameter("lng") !=
> > null){
> >                         Double lat = Double.parseDouble(
> > request.getParameter("lat") );
> >                         Double lng = Double.parseDouble(
> > request.getParameter("lng") );
> >                         Double radiusInMeters = Double.parseDouble(
> > request.getParameter("radius") ) / 2;
> >
> >                         Geometry location =
> GeometryService.getPolygon(new
> > GeoPoint(lat, lng),
> > radiusInMeters.intValue());
> >                         groups =
> > groupService.getGroupsOnLocation(location);
> >
> >                         System.out.println("returnBody");
> >                         return zone.getBody();
> >                 }
> >                 System.out.println("null");
> >                 return null;
> >         }
> >
> > but, .. i dont know how to update the zone now with tapestry.
> zone.getBody
> > does not work. The only thing i managed was a hard approach within JS:
> >
> > window.location.reload();
> >
> >
> > my full class:
> >
> >
> > package com.airwriting.frontend.pages.group;
> >
> > import java.util.ArrayList;
> >
> > import java.util.Date;
> >
> > import java.util.List;
> >
> >
> > import org.apache.tapestry5.ComponentResources;
> > import org.apache.tapestry5.Link;
> > import org.apache.tapestry5.annotations.Import;
> > import org.apache.tapestry5.annotations.InjectComponent;
> > import org.apache.tapestry5.annotations.Persist;
> > import org.apache.tapestry5.annotations.Property;
> > import org.apache.tapestry5.corelib.components.Zone;
> > import org.apache.tapestry5.ioc.annotations.Inject;
> > import org.apache.tapestry5.services.Request;
> > import org.apache.tapestry5.services.javascript.JavaScriptSupport;
> >
> > import se.unbound.tapestry.breadcrumbs.BreadCrumb;
> >
> > import com.airwriting.configuration.Configuration;
> > import com.airwriting.domain.GeoPoint;
> > import com.airwriting.domain.Group;
> > import com.airwriting.service.GeometryService;
> > import com.airwriting.service.data.GroupService;
> > import com.vividsolutions.jts.geom.Geometry;
> >
> > @Import(library = {
> >                 "context:js/browselocalgroups.js"
> >         })
> > @BreadCrumb(titleKey="group/ListLocalGroups")
> > public class ListLocalGroups {
> >
> >         @Inject
> >         private GroupService groupService;
> >         @Inject
> >         private JavaScriptSupport jsSupport;
> >         @Inject
> >         private Request request;
> >         @Inject
> >         private ComponentResources componentResources;
> >         @Property
> >         private Geometry location;
> >
> >
> >         @Inject
> >         private Configuration configuration;
> >
> >         @Property
> >         private String googleMapsKey;
> >
> >         @Persist
> >         @Property
> >         private List<Group> groups;
> >
> >         @InjectComponent
> >         private Zone zone;
> >
> >         @Property
> >         private Group curGroup;
> >
> >         @Persist
> >         private Date lastUpdate;
> >
> >         public void setupRender() {
> >
> >
> >                 if (request.getServerName().endsWith(".net")){
> >                         googleMapsKey = configuration.getString("
> > googleMaps.key.net");
> >                 }else if (request.getServerName().endsWith(".de")){
> >                         googleMapsKey = configuration.getString("
> > googleMaps.key.de");
> >                 }else if (request.getServerName().endsWith(".at")){
> >                         googleMapsKey = configuration.getString("
> > googleMaps.key.at");
> >                 }
> >                 else {//.com
> >                         googleMapsKey =
> > configuration.getString("googleMaps.key");
> >                 }
> >
> >                 System.out.println("setupRender");
> >
> >                 if (groups == null || groups.size() == 0){
> >
> >                         System.out.println("createEventLink");
> >                         Link linkGetGroupsOnLocation =
> > componentResources.createEventLink("getGroupsOnLocation");
> >                         groups = new ArrayList<Group>();
> >
> >                         if (lastUpdate == null ){
> >                                 updatePage(linkGetGroupsOnLocation);
> >
> >                         }else if (minutesDiff(lastUpdate, new Date()) >
> 1){
> >                                 updatePage(linkGetGroupsOnLocation);
> >
> >                         }
> >
> >                 }else {
> >
> >                 }
> >         }
> >
> >         private void updatePage(Link linkGetGroupsOnLocation) {
> >                 jsSupport.addScript(
> >                                 "init('%s');",
> >                                 linkGetGroupsOnLocation.toURI());
> >                 lastUpdate = new Date();
> >         }
> >
> >
> >
> >         public Object onGetGroupsOnLocation(){
> >                 System.out.println("onGetGroupsOnLocation");
> >
> >                 if (request.getParameter("lat") != null &&
> > request.getParameter("lng") !=
> > null){
> >                         Double lat = Double.parseDouble(
> > request.getParameter("lat") );
> >                         Double lng = Double.parseDouble(
> > request.getParameter("lng") );
> >                         Double radiusInMeters = Double.parseDouble(
> > request.getParameter("radius") ) / 2;
> >
> >                         Geometry location =
> GeometryService.getPolygon(new
> > GeoPoint(lat, lng),
> > radiusInMeters.intValue());
> >                         groups =
> > groupService.getGroupsOnLocation(location);
> >
> >                         System.out.println("returnBody");
> >                         return zone.getBody();
> >                 }
> >                 System.out.println("null");
> >                 return null;
> >         }
> >
> >         private static int minutesDiff(Date earlierDate, Date laterDate)
> >         {
> >             if( earlierDate == null || laterDate == null ) return 0;
> >
> >             return (int)((laterDate.getTime()/60000) -
> > (earlierDate.getTime()/60000));
> >         }
> >
> > }
> >
> >
> >
> >
> > --
> > View this message in context:
> >
> http://tapestry.1045711.n5.nabble.com/updating-a-zone-from-javascript-tp5716428.html
> > Sent from the Tapestry - User mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5716429&i=1>
> > For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5716429&i=2>
> >
> >
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://tapestry.1045711.n5.nabble.com/updating-a-zone-from-javascript-tp5716428p5716429.html
>  To unsubscribe from updating a zone from javascript, click here<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5716428&code=YWxleGFuZGVyLnNvbW1lckBnbWFpbC5jb218NTcxNjQyOHwxMDUzMzQxMzM4>
> .
> NAML<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://tapestry.1045711.n5.nabble.com/updating-a-zone-from-javascript-tp5716428p5716430.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

Re: updating a zone from javascript

Posted by Dieter Sauvillers <di...@gmail.com>.
Hi

When is the function  onGetLatLng(gLatLng) called? When it's on a user
event you can maybe have a look at the zone updater from jumpstart.

http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/onevent

kind regards

On 21 September 2012 13:40, sommeralex <al...@gmail.com> wrote:

> Hello!
>
> I have a javascript function,
>
> function onGetLatLng(gLatLng){
>
>         if(gLatLng == null) {
>                 alert("Sorry, we couldn't find this address.");
>                 return false;
>         }
>
>         new Ajax.Request(urlGetGroupsOnLocation, { onSuccess: updatePage,
>                 parameters: 'lat='+gLatLng.lat() + '&lng=' + gLatLng.lng()
> + '&radius=' +
> 50000});
> }
>
> ..which is calling urlGetGroupsOnLocation in my class:
>
>         public Object onGetGroupsOnLocation(){
>                 System.out.println("onGetGroupsOnLocation");
>
>                 if (request.getParameter("lat") != null &&
> request.getParameter("lng") !=
> null){
>                         Double lat = Double.parseDouble(
> request.getParameter("lat") );
>                         Double lng = Double.parseDouble(
> request.getParameter("lng") );
>                         Double radiusInMeters = Double.parseDouble(
> request.getParameter("radius") ) / 2;
>
>                         Geometry location = GeometryService.getPolygon(new
> GeoPoint(lat, lng),
> radiusInMeters.intValue());
>                         groups =
> groupService.getGroupsOnLocation(location);
>
>                         System.out.println("returnBody");
>                         return zone.getBody();
>                 }
>                 System.out.println("null");
>                 return null;
>         }
>
> but, .. i dont know how to update the zone now with tapestry. zone.getBody
> does not work. The only thing i managed was a hard approach within JS:
>
> window.location.reload();
>
>
> my full class:
>
>
> package com.airwriting.frontend.pages.group;
>
> import java.util.ArrayList;
>
> import java.util.Date;
>
> import java.util.List;
>
>
> import org.apache.tapestry5.ComponentResources;
> import org.apache.tapestry5.Link;
> import org.apache.tapestry5.annotations.Import;
> import org.apache.tapestry5.annotations.InjectComponent;
> import org.apache.tapestry5.annotations.Persist;
> import org.apache.tapestry5.annotations.Property;
> import org.apache.tapestry5.corelib.components.Zone;
> import org.apache.tapestry5.ioc.annotations.Inject;
> import org.apache.tapestry5.services.Request;
> import org.apache.tapestry5.services.javascript.JavaScriptSupport;
>
> import se.unbound.tapestry.breadcrumbs.BreadCrumb;
>
> import com.airwriting.configuration.Configuration;
> import com.airwriting.domain.GeoPoint;
> import com.airwriting.domain.Group;
> import com.airwriting.service.GeometryService;
> import com.airwriting.service.data.GroupService;
> import com.vividsolutions.jts.geom.Geometry;
>
> @Import(library = {
>                 "context:js/browselocalgroups.js"
>         })
> @BreadCrumb(titleKey="group/ListLocalGroups")
> public class ListLocalGroups {
>
>         @Inject
>         private GroupService groupService;
>         @Inject
>         private JavaScriptSupport jsSupport;
>         @Inject
>         private Request request;
>         @Inject
>         private ComponentResources componentResources;
>         @Property
>         private Geometry location;
>
>
>         @Inject
>         private Configuration configuration;
>
>         @Property
>         private String googleMapsKey;
>
>         @Persist
>         @Property
>         private List<Group> groups;
>
>         @InjectComponent
>         private Zone zone;
>
>         @Property
>         private Group curGroup;
>
>         @Persist
>         private Date lastUpdate;
>
>         public void setupRender() {
>
>
>                 if (request.getServerName().endsWith(".net")){
>                         googleMapsKey = configuration.getString("
> googleMaps.key.net");
>                 }else if (request.getServerName().endsWith(".de")){
>                         googleMapsKey = configuration.getString("
> googleMaps.key.de");
>                 }else if (request.getServerName().endsWith(".at")){
>                         googleMapsKey = configuration.getString("
> googleMaps.key.at");
>                 }
>                 else {//.com
>                         googleMapsKey =
> configuration.getString("googleMaps.key");
>                 }
>
>                 System.out.println("setupRender");
>
>                 if (groups == null || groups.size() == 0){
>
>                         System.out.println("createEventLink");
>                         Link linkGetGroupsOnLocation =
> componentResources.createEventLink("getGroupsOnLocation");
>                         groups = new ArrayList<Group>();
>
>                         if (lastUpdate == null ){
>                                 updatePage(linkGetGroupsOnLocation);
>
>                         }else if (minutesDiff(lastUpdate, new Date()) > 1){
>                                 updatePage(linkGetGroupsOnLocation);
>
>                         }
>
>                 }else {
>
>                 }
>         }
>
>         private void updatePage(Link linkGetGroupsOnLocation) {
>                 jsSupport.addScript(
>                                 "init('%s');",
>                                 linkGetGroupsOnLocation.toURI());
>                 lastUpdate = new Date();
>         }
>
>
>
>         public Object onGetGroupsOnLocation(){
>                 System.out.println("onGetGroupsOnLocation");
>
>                 if (request.getParameter("lat") != null &&
> request.getParameter("lng") !=
> null){
>                         Double lat = Double.parseDouble(
> request.getParameter("lat") );
>                         Double lng = Double.parseDouble(
> request.getParameter("lng") );
>                         Double radiusInMeters = Double.parseDouble(
> request.getParameter("radius") ) / 2;
>
>                         Geometry location = GeometryService.getPolygon(new
> GeoPoint(lat, lng),
> radiusInMeters.intValue());
>                         groups =
> groupService.getGroupsOnLocation(location);
>
>                         System.out.println("returnBody");
>                         return zone.getBody();
>                 }
>                 System.out.println("null");
>                 return null;
>         }
>
>         private static int minutesDiff(Date earlierDate, Date laterDate)
>         {
>             if( earlierDate == null || laterDate == null ) return 0;
>
>             return (int)((laterDate.getTime()/60000) -
> (earlierDate.getTime()/60000));
>         }
>
> }
>
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/updating-a-zone-from-javascript-tp5716428.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>