If you just need to make sure that data are available for multiple requests within the same session, use SessionVar, if you need them available for multiple AJAX requests within same page, then RequestVar is all you need.
But please, tell us your use case, then we'll be able to help you better.
Jan
> --
> You received this message because you are subscribed to the Google Groups "Lift" group.
> To post to this group, send email to lif...@googlegroups.com.
> To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
> Remote service just redirect browser to callback URL.
> Everything happens in the browser.
A while ago, before I started to use Lift I was implementing a similar system, that communicated with a third party service by redirection (credit card payments done through bank's cardpay system)
At that time, I did it by persisting an object and passing an ID, that was also included in a callback request and by that ID I was able to pick up a correct object.
However, I'm wondering, if it's all done in a browser by redirection, then when you are redirected back, you should still have the same session if you didn't quit your browser. Thus SessionVar should serve you well even without passing a jsessionid to a remote service. But maybe I'm missing something...
>
> There is no problem with passing JSESSIONID.
> I'm just curious if alternative solution is possible because I know that Lift is able to pass objects using request variables.
Personaly I prefer to pass around as little as possible and have as much data kept on a server as I can. Because you never know what may happen with it while travelling around. Thus I'd use such solution (if it exists) only if I had no other choice. But that's just me...
At that time, I did it by persisting an object and passing an ID, that was also included in a callback request and by that ID I was able to pick up a correct object.
However, I'm wondering, if it's all done in a browser by redirection, then when you are redirected back, you should still have the same session if you didn't quit your browser. Thus SessionVar should serve you well even without passing a jsessionid to a remote service. But maybe I'm missing something...
Personaly I prefer to pass around as little as possible and have as much data kept on a server as I can. Because you never know what may happen with it while travelling around. Thus I'd use such solution (if it exists) only if I had no other choice. But that's just me...
Hello Ján.At that time, I did it by persisting an object and passing an ID, that was also included in a callback request and by that ID I was able to pick up a correct object.
How did you get object ID?
How did you pick up object back?
However, I'm wondering, if it's all done in a browser by redirection, then when you are redirected back, you should still have the same session if you didn't quit your browser. Thus SessionVar should serve you well even without passing a jsessionid to a remote service. But maybe I'm missing something...
Yes, I also were wondered (having PHP experience) that session is not reliable, at least in development mode under SBT′s jetty-run.
I've wrote about this in the group.
Personaly I prefer to pass around as little as possible and have as much data kept on a server as I can. Because you never know what may happen with it while travelling around. Thus I'd use such solution (if it exists) only if I had no other choice. But that's just me...
I expect that passing object ID′s is comparable with passing session id.
I did not mean to pass whole object around similar to RequestVar feature of the Lift.
--
Sergey
Thank you.
--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
On Wed, Apr 13, 2011 at 11:23 AM, Sergey Trofimov <sergey....@gmail.com> wrote:
Remote service just redirect browser to callback URL.
Everything happens in the browser.
There is no problem with passing JSESSIONID.
I'm just curious if alternative solution is possible because I know that Lift is able to pass objects using request variables.
Personally, I'd do this with RequestVars rather than with SessionVars because that gives you scope over the variables (they're good for the scope of a single request rather than for the entire session).
So, if you've got a couple of RequestVars, you can do the following:object rv1 extends RequestVar...
object rv2 extends RequestVar...
def snapshot(): () => Unit = {
val v1 = rv1.get
val v2 = rv2.get
() => {rv1.set(v1); rv2.set(v2)}
}
def buildCallbackURL(baseURL: String): String = S.fmapFunc(snapshot())(key => Helpers.appendFuncToURL(baseURL, key +"=_"))
The snapshot method creates a function that will restore the RequestVars to the state that they had when it was called. The buildCallbackURL method takes a base URL (built using whatever mechanism you choose) and appends the restore function to it. When that URL is hit on the server, the RequestVars will be restored and away you go.
On Thu, Apr 14, 2011 at 9:28 AM, David Pollak <feeder.of...@gmail.com> wrote:
On Wed, Apr 13, 2011 at 11:23 AM, Sergey Trofimov <sergey....@gmail.com> wrote:
Remote service just redirect browser to callback URL.
Everything happens in the browser.
There is no problem with passing JSESSIONID.
I'm just curious if alternative solution is possible because I know that Lift is able to pass objects using request variables.
Personally, I'd do this with RequestVars rather than with SessionVars because that gives you scope over the variables (they're good for the scope of a single request rather than for the entire session).
So, if you've got a couple of RequestVars, you can do the following:object rv1 extends RequestVar...
object rv2 extends RequestVar...
def snapshot(): () => Unit = {
val v1 = rv1.get
val v2 = rv2.get
() => {rv1.set(v1); rv2.set(v2)}
}
def buildCallbackURL(baseURL: String): String = S.fmapFunc(snapshot())(key => Helpers.appendFuncToURL(baseURL, key +"=_"))
The snapshot method creates a function that will restore the RequestVars to the state that they had when it was called. The buildCallbackURL method takes a base URL (built using whatever mechanism you choose) and appends the restore function to it. When that URL is hit on the server, the RequestVars will be restored and away you go.
Neat code! Maybe it would be useful to have a generalization in the library?1. def snapshot(rvs: RequestVar*): ()=>Unit2. def urlWithState(baseUrl: String, state: ()=>Unit)
This is one of those code snippets I see and want to find a way to use
them asap :) There is still so much to learn about Lift ...
Diego
#callback
--
Diego Medina
Web Developer
http://www.fmpwizard.com