Hi Arno, 

Thx for your your answer. If i am trying what you say, i get this error
message:

Ajax failure: Status 500 for /group/listlocalgroups:getgroupsonlocation:
org.apache.tapestry5.ioc.internal.OperationException
Communication with the server failed:
org.apache.tapestry5.ioc.internal.OperationException

FULL CODE:

package com.airwriting.frontend.pages.group;

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.Property;
import org.apache.tapestry5.corelib.components.Zone;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.json.JSONArray;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.Request;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;

import com.myProj.domain.GeoPoint;
import com.myProj.domain.Group;
import com.myProj.service.GeometryService;
import com.myProj.service.data.GroupService;
import com.vividsolutions.jts.geom.Geometry;

@Import(library = {
                "context:js/browselocalgroups.js" 
        })
public class ListLocalGroups {
        
        @Inject
        private GroupService groupService;
        @Inject
        private JavaScriptSupport jsSupport;
        @Inject
        private Request request;
        @Inject
        private ComponentResources componentResources;
        @Property
        private Geometry location;
                
        @Property
        private List<Group> groups;
                
        @InjectComponent
        private Zone zone;
        
        @SuppressWarnings("unused")
        @Property
        private Group curGroup;
        
        public void setupRender() {
                Link linkGetGroupsOnLocation =
componentResources.createEventLink("getGroupsOnLocation");

                
                jsSupport.addScript(
                                "init('%s');", 
                                linkGetGroupsOnLocation.toURI());
        }
        
        public JSONArray onGetGroupsOnLocation(){
                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);
                JSONArray jsGroups = new JSONArray();
                for(Group group : groups){
                        JSONObject jsGroup = group.toJSON();
                        jsGroup.put("lat", 
group.getScope().getCentroid().getY());
                        jsGroup.put("lng", 
group.getScope().getCentroid().getX());
                        jsGroups.put(jsGroup);
                }
                return jsGroups;
        }
        
}


TML

<t:layout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>

        <div class ="map" id="map"></div>
        <t:googleMaps />


<t:zone t:id="zone" id="zone">          
        <div id="zoneDiv">
        
        <t:loop source="groups" value="curGroup">

                <div style="float:left">
                        test
                </div> 
        </t:loop>
        
        </div>
</t:zone>
</t:layout>

JAVASCRIPT

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;
        }
         alert ("ajax");
        new Ajax.Request(urlGetGroupsOnLocation, { onSuccess: drawGroups,
                parameters: 'lat='+gLatLng.lat() + '&lng=' + gLatLng.lng() + 
'&radius=' +
50000});
}

function drawGroups(response){
         alert ("draw");
        var groupArray = response.responseJSON;
        var list = "<ol>";
        for (var i = 0; i < groupArray .length; i++) {
            var group = groupArray [i];

           // var link = "<t:pagelink page=\&quot;group/show\&quot;
context=\&quot;&quot; + group['id'] + &quot;\&quot;>link</t:pagelink>"
            
            var link = "<a t:type=\&quot;pagelink\&quot; 
href=\&quot;show/&quot; +
+ group['id'] +   &quot;\&quot; t:page=\&quot;group/show\&quot;
t:context=&quot; + group['id'] + &quot;>"+ group['name'] +" ";

                list +="<li>"+link +"</li>";


            // If property names are known beforehand, you can also just do e.g.
            // alert(object.id + ',' + object.Title);
        }

        
        
         //list +="</ol>";
         //document.getElementById("list").innerHTML=list;
         alert ("zone");         
         var zoneObject=Tapestry.findZoneManagerForZone('zone');
         zoneObject.updateFromURL(urlGetGroupsOnLocation, {}); 
         alert ("ok");
}





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

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

Reply via email to