Re: Query Mobile & Tapestry

2013-04-01 Thread Thiago H de Paula Figueiredo
On Sat, 30 Mar 2013 20:07:18 -0300, Alexander Sommer  
 wrote:



Hi!


Hi!


I was reading in the forum (eg
http://mail-archives.apache.org/mod_mbox/tapestry-users/201201.mbox/%3ccd6ed1fa-1e5c-4cbb-a6e9-67eeb842e...@mail-nic-00.intern.albourne.com%3E),
that jquery is complicating (correct me if this is not true!!) things due
to prototype used in tapestry.


Have you tried tapestry-jquery with the suppress Prototype configuration  
turned on? This will make Tapestry work completely free of Prototype. This  
way, you don't need to throw the baby together with the bath water. ;)



if I want to use this service, I run into the crossDomain problem with
javascript, because my mobile webapp for example is (for testing  
purposes) hosted here: http://www.learnclip.com/airwritingweb/ (so not on

airwriting.com)


Now this is something which is a pure JavaScript security issue, not  
related to Tapestry.


--
Thiago H. de Paula Figueiredo

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



Query Mobile & Tapestry

2013-03-30 Thread Alexander Sommer
Hi!

I am trying to build a mobile web app based on jquery mobile. For that
reason, I need to reuse my services built with tapestry - which turned out
not being as trivial as expected.

I was reading in the forum (eg
http://mail-archives.apache.org/mod_mbox/tapestry-users/201201.mbox/%3ccd6ed1fa-1e5c-4cbb-a6e9-67eeb842e...@mail-nic-00.intern.albourne.com%3E),
that jquery is complicating (correct me if this is not true!!) things due
to prototype used in tapestry. For that reason, I would like to try a 100%
clean approach - my web app client should not be depended on tapestry
(GUI!) at all, I just want to use my tapestry services.

one service for example is:

http://www.airwriting.com/mobile/public:getLocalGroups?lat=48.15&lng=16.3

which is returning valid json. (check for non believers http://jsonlint.com/
)

BUT

if I want to use this service, I run into the crossDomain problem with
javascript, because my mobile webapp for example is (for testing purposes)
hosted here: http://www.learnclip.com/airwritingweb/ (so not on
airwriting.com)

Now, I see two options to solve this crossDomain issue;

*A.*
Run the web app build with jquery on the same domain. -> how can I do this?
Is it possible to copy the whole web app project just to some tapestry
folder and tell tapestry that it should "ignore" that folder - but still
making it accessable from the outside? eg. via
www.airwriting.com/mobile/jquery ?

*B.*
if i got it right (http://api.jquery.com/jQuery.getJSON/), the function

$.getJSON in

jquery mobile needs  a ?jsoncallback=? parameter, in my case

http://www.airwriting.com/mobile/public:getLocalGroups?lat=48.15&lng=16.3?jsoncallback=
?

but I really have no idea how I have to handle the jsoncallback in my
service method:

private final String CONTENT_TYPE = "application/javascript";

public StreamResponse onGetLocalGroups(){
Double latitude = Double.parseDouble(request.getParameter("lat"));
Double longitude = Double.parseDouble(request.getParameter("lng"));

List groups = groupService.getGroupsOnLocation(new
GeoPoint(latitude, longitude).toPoint(), limit, offset);

JSONArray jsGroups = new JSONArray();
for( Group group : groups ){
jsGroups.put(group.toJSON());
}
return new TextStreamResponse(CONTENT_TYPE, jsGroups.toString());
}


just calling (from a not airwriting.com domain)


(function() {
  var url = "
http://www.airwriting.com/mobile/public:getLocalGroups?lat=48.15&lng=16.3";;
  $.getJSON( url, {
format: "json"
  })
  .done(function( data ) {
$.each( data.items, function( i, item ) {

   alert (item);

});
  });
})();




DOES NOT WORK - so i guess it has something to do with the callback.
Reading me deeper into the jsonP theory, my understanding focuses on the
need for writing somekind of filter in the filterrequestchain for handling
this kind of crossDomain request. puh.. (
http://code.google.com/p/jsonp-java/)


any help is highly appreciated.. thx,
alex


further, good links:
http://json-p.org/
http://alotaiba.github.com/FlyJSONP/#!/demo