>Actually if you're grabbing the href from StatefulSnippet.link then you 
>shouldn't need to write registerThisSnippet, or redirect.
>Can you verify that the code block passed to StatefulSnippet.link is getting 
>executed?

That's what I thought. I checked and the code block is not getting
called.

val red = urlEncode(S.hostAndPath + (link("/jSearch", () => println("I
was called " + fn), NodeSeq.Empty) \ "@href").text)
println("redirect url: " + urlDecode(red))

The second print statement does print a valid looking url:
redirect url: http://localhost:8080/jSearch?F1169402556414Y5H=_

However the "I was called " println block is never called.


> I don't think Scala's "XPath" supports "@attributes". You have to use the API 
> of scala.xml.Elem to look up the value of an attribute.

It does actually. Programming in Scala pg. 520

> But there's a better way: do what StatefulSnippet.link does yourself. Look up 
> the source. I think the method you want is S.fmapFunc or something like that 
> if I'm > not getting mixed up.

Yes, I thought about doing that. I went thought the source and found
that method but I am not really sure what to put there. All I want to
to is return to the third form with access to data from the previous
two forms. The third form comes up but the data from the previous two
is gone.

At this point I created a new git branch that used DispatchSnippets
and SessionVars and in works so I need to move on.

Thanks again for your help.

-A

On Mar 4, 3:37 pm, Naftoli Gugenheim <[email protected]> wrote:
> I don't think Scala's "XPath" supports "@attributes". You have to use the API 
> of scala.xml.Elem to look up the value of an attribute.
> But there's a better way: do what StatefulSnippet.link does yourself. Look up 
> the source. I think the method you want is S.fmapFunc or something like that 
> if I'm not getting mixed up.
>
> -------------------------------------
>
> andythedestroyer<[email protected]> 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 <[email protected]> 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<[email protected]> 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 [email protected].
> > To unsubscribe from this group, send email to 
> > [email protected].
> > 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 [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.

Reply via email to