Yeah it does... in essence not very different from initial proposal
since internally redirectTo from stateful snippet does the same thing:
binds a function to be executed upon redirect.

On Jan 30, 5:47 pm, Derek Chen-Becker <dchenbec...@gmail.com> wrote:
> Unless I'm missing something the stateful snippet should be working. The
> this.redirectTo call should be invoking the StatefulSnippet's redirectTo,
> which should associate the same snippet instance with the new page. That
> should allow access to the same var. I just coded up a test app (attached)
> and it works fine using very similar code.
>
> On Fri, Jan 30, 2009 at 12:36 AM, Marius <marius.dan...@gmail.com> wrote:
>
> > On Jan 29, 10:54 pm, Sergey Andreev <andser...@gmail.com> wrote:
> > > Hi Liftlers,
> > > I am migrating one of my application to the lift as a way to learn it and
> > i
> > > would like to ask a question.
>
> > > After submitting a form i would like to do a redirect and show the
> > submitted
> > > values on the other template. I have 2 templates and i use the same
> > snippet
> > > in both of them to render a dynamic content.
> > > As far as i understand there are 2 ways to make it work: saving state
> > using
> > > SessionVars(which works for me) or extending StatefulSnippet and calling
> > > this.redirectTo on it (looking at the sources it should register the
> > > stateful snippet in the session). I've tried extending StatefulSnippet
> > but
> > > it doesn't work for me. A hashed value is added to the redirect url which
> > > should map to the stateful snippet but the state is lost. I don't
> > understand
> > > what i am doing wrong.
>
> > > The simplified example of the code:
>
> > > class MySnippet extend StatefulSnippet {
> > >   private var myValues: List[String] = List()
>
> > >   val dispatch.. = {
> > >     case "save" => save_
> > >     case "show" => show _
> > >   }
>
> > >   def show = {
> > >     myValues.foreach(Log.info(_)) //nothing here
> > >   }
>
> > >   def save(xhtml: NodeSeq) : NodeSeq = {
> > >     def processForm = {
> > >       myValues.foreach(Log.info(_)) //submitted values are printed out
> > >       this.redirectTo("/show")
> > >     }
>
> > Unless I'm missing something I do not this your values can be shown in
> > the new template. There is an overloaded S.redirectTo where you can
> > specify a function to be executed when the redirect is receives. Hence
> > here you can pass state. See
>
> > def redirectTo[T](where: String, func: () => Unit): T
>
> > In this function you could probably set some RequestVar holding your
> > needed state and when you snippet is rendered in the /show page you
> > just read the info from these RequestVar(s).
>
> > >     bind("render", xhtml,
> > >        ...... //render textboxes and register functions which add values
> > to
> > > the myValues list
> > >        "submit" -> submit("Submit", processForm)
> > >   }
>
> > > }
>
> > > Thanks,
> > > Sergey
> > > P.S. The more i learn about Lift the more i like it. Thank you David and
> > all
> > > lift committers!!!
>
>
>
>  teststateful.tgz
> 7KViewDownload
--~--~---------~--~----~------------~-------~--~----~
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