I would do the first option, which I don't see as 'unLifty', but
perhaps someone who knows Lift better than I do can comment on your
options.

Peter Robinett

On Jul 28, 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 Darilekhttp://thewordnerd.info
--~--~---------~--~----~------------~-------~--~----~
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