On Jan 30, 9: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).


To me more specific I was referring to something like:


def myFunc(state: List[String])() { // a curried function

   // here set the state on a RequestVar

}

from you submit function call:

S.redirectTo("/show", myFunc(myValues) _)


>
>
>
> >     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!!!
--~--~---------~--~----~------------~-------~--~----~
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