Although it would be cool to figure out how to pause and resume
StatefulSnippets, I just reworked it to use DispatchSnippets and
SessionVars and in only took 10 mins.

Thanks again to Naftoli.

-A

On Mar 4, 3:03 pm, andythedestroyer <andythedestro...@gmail.com>
wrote:
> Naftoli,
>
> Thanks for the response.
>
> I don't think I understand your post very well. I have two redirectTos
> in the code and I tried putting registerThisSnippet in both. This what
> I tried.
>
> object mySnip extends SessionVar[Box[Wizard]](Emtpy)
> class Wizard extends StatefulSnippet with Logger {
> ....
> def doRedirect = {
> mySnip.set( Full(this) )
> val returnPath = urlEncode(
>  S.hostAndPath + ( link("/lastPage", () => redirectTo("/lastPage"),
> NodeSeq.Empty) \ "@href).text
> )
>
> S.redirectTo( third_party_url +"?return=" + returnPath,
> mySnip.get.get.registerThisSnippet())
>
> }
> }
>
> And
>
> object mySnip extends SessionVar[Box[Wizard]](Emtpy)
> class Wizard extends StatefulSnippet with Logger {
> ....
> def doRedirect = {
> mySnip.set( Full(this) )
> val returnPath = urlEncode(
>   S.hostAndPath + ( link("/lastPage", () => S.redirectTo("/lastPage",
> mySnip.get.get.registerThisSnippet()), NodeSeq.Empty) \ "@href).text
> )
>
> redirectTo( third_party_url +"?return=" + returnPath)
>
> }
> }
>
> Neither worked. The SessionVar shouldn't go out of scope. It seems
> like I should be able to generate a link and just take the href from
> the generated link. I don't understand why that doesn't work.
>
> Thanks,
> Andy
>
> On Mar 4, 2:26 pm, Naftoli Gugenheim <naftoli...@gmail.com> wrote:
>
> > You have to save the snippet instance in a variable somewhere that won't go 
> > out of scope, and then in redirectTo's second parameter write 
> > instance.registerThisSnippet.
>
> > -------------------------------------
>
> > andythedestroyer<andythedestro...@gmail.com> wrote:
>
> > Hello,
>
> > I have a simple use case where there is a 2 page form wizard then a
> > redirect to a third party ( for some external validation ) which
> > redirects back to a third and final page of the wizard.
>
> > I know I could just use snippets and SessionVars to manage this but I
> > have been using StatefullSnippets and would like to try to solve this
> > problem rather than accept failure and use another method.
>
> > I pass the url for the third page to the third party to redirect to
> > when their work is done. The problem is the snippet state is lost
> > after the redirect. I have tried many different things and it seems
> > like something like this should work.
>
> > // in the processing done before redirect to third party.
> > // assemble the return path url.
>
> > class Wizard extends StatefulSnippet with Logger {
> > ....
> > def doRedirect = {
> > val returnPath = urlEncode(S.hostAndPath + ( link("/lastPage", () =>
> > redirectTo("/lastPage"), NodeSeq.Empty) \ "@href).text)
>
> > redirectTo( third_party_url +"?return=" + returnPath)
>
> > }
> > }
>
> > This does generate a return path like "http://localhost:8080/lastPage?
> > F1151306194165AHF=_" , however all state is gone after the third party
> > redirects back to the site, however if I don't redirect to the third
> > party and instead redirect the "val returnPath" I construct directly,
> > state is maintained.
>
> > Is it possible to resume my StatefulSnippet? Or shall I just use
> > something else?
>
> > Thanks to all who read and or respond.
>
> > -Andy
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Lift" group.
> > To post to this group, send email to lift...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > liftweb+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/liftweb?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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