I'd do the REST API thing.  The mechanisms that Lift has for handling API
calls from the browser are numerous, but they are associated with a session
(you can do ajaxCall or a S.buildJsonFunc).  If your client is going to be
disconnected, periodically wake up, make an HTTP call on your app and then
go back to sleep, the best thing to use is a statelessDispatch and some
authentication mechanism as part of the call (truly RESTful and stateless).

Also, there's very little that's "non Liftish."  Lift is about allowing you
to focus on the business logic at hand, but sometimes the business logic is
"update this" and REST is good for "update this".

On Tue, Jul 28, 2009 at 10:57 AM, Nolan Darilek <no...@thewordnerd.info>wrote:

>
> I have a project that will use the geolocation API in Firefox 3.5,
> Google Gears and other JS frameworks. It will need to keep the user's
> position updated using the watchPosition API, fetching nearby POIs and
> such whenever the position changes.
>
> I'm actually fairly new to AJAX, and am trying to figure out the best
> way to do this. Most of the AJAX examples I've seen involve user
> interaction, such as entering into a text field than removing focus, or
> waiting on state updates, as with comet. In this case, there's state
> that may update often or never, and those updates will be triggered by a
> callback function in the background, with no user interaction into which
> I can hook. I also don't want to leave a Comet connection open to the
> app waiting on updates, since the app may see mobile use, and I can't
> imagine holding open a connection being great for battery life.
>
> I'm wondering what the best way to do this would be, while staying
> fairly close to what Lift offers? Thus far I have two options.
>
> 1. Create a REST API and have the Javascript call a specified URL
> whenever the position changes, inserting the resulting JSON into the
> page at appropriate places. This works, but seems like it'd involve lots
> of extra effort, as well as straying away from Lift/Scala's added
> benefits into the dynamicity of JS, which I'm not entirely comfortable
> with.
>
> 2. Create a hidden JSON form on the page. When the position changes, the
> JS callback function fills out and submits the form in the background.
> This seems a bit hackish, with the hidden form and all, but this makes
> the problem one that is on a bit less shaky Lift ground. I can then use
> Lift's provided functionality to generate JS for replacing page contents
> with the results of evaluating the form submission.
>
> I'm basically going from the Lift book here. Most ideal, I'd think,
> would be if there was some way to have my callback function call a
> snippet directly and be handed back the JS needed, without having to
> create a separate web service API for this one call. Is the JSON form
> method the best option here? Or is there some new shiny in 1.1 that
> isn't documented in the Lift book yet? (or perhaps it *is* documented
> and I'm just missing it. :)
>
> Thanks.
>
>
>
> --
> Nolan Darilek
> http://thewordnerd.info
>
>
> >
>


-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to