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/04/22 23:00:00 UTC
updating a zone (serversided)
Hello!
I want that my zone is automatically updated. I am able to update my zone
with a actionLink, but not from within the method (which gets called after
geolocation coordinates are retrieved) so, onGetGroupsOnLocation() is called
and my groupList is filled with groups. But the zone is not updated. Only if
i am clicking on my actionLink. hm..
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 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/mobilebrowsegroups.js"
})
public class BrowseGroups {
@Property
@Persist
private List<Group> groups;
@Property
private Group group;
@InjectComponent
private Zone listZone;
@Inject
private GroupService groupService;
@Inject
private JavaScriptSupport jsSupport;
@Inject
private Request request;
@Inject
private ComponentResources componentResources;
public void setupRender() {
Link linkGetGroupsOnLocation =
componentResources.createEventLink("getGroupsOnLocation");
jsSupport.addScript("init('%s');", linkGetGroupsOnLocation.toURI());
}
Object onActionFromUpdate()
{
return listZone.getBody();
}
public Object onGetGroupsOnLocation(){
Double lat = Double.parseDouble( request.getParameter("lat") );
Double lng = Double.parseDouble( request.getParameter("lng") );
Geometry location = GeometryService.getPolygon(new GeoPoint(lat, lng),
50000);
groups = groupService.getGroupsOnLocation(location);
System.out.println(groups.size());
return listZone.getBody();
}
}
TML
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
<t:zone t:id="listZone" id="listZone" visible="false">
hello
<t:loop source="groups" value="group">
${group.name}
</t:loop>
</t:zone>
<t:actionlink t:id="update" zone="listZone">update</t:actionlink>
</html>
JAVASCRIPT
var urlGetGroupsOnLocation;
function init(url) {
urlGetGroupsOnLocation = url;
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
new Ajax.Request(urlGetGroupsOnLocation, {
onSuccess : finish,
parameters : 'lat=' + position.coords.latitude + '&lng=' +
position.coords.longitude
});
}, function(msg) {
alert ("geolocation not supported..")
});
}
}
function finish(response){
}
--
View this message in context: http://tapestry.1045711.n5.nabble.com/updating-a-zone-serversided-tp5657947p5657947.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