Also, if the class for the snippet couldn't be found, Lift should have
output a message to that effect on the console. If it didn't, then
*that's*a bug.

Derek

On Mon, Feb 2, 2009 at 8:00 AM, Derek Chen-Becker <dchenbec...@gmail.com>wrote:

> I think the convention is to either properly capitalize the snippet tag to
> match the class name, as you've done, or to use underscores to indicate
> camel case, a la
>
> show_market
>
> I don't think that Lift handles "mixed" camel case, but it's been a while
> since I've looked at that part of the code.
>
> Derek
>
>
> On Sun, Feb 1, 2009 at 9:20 AM, Sergey Andreev <andser...@gmail.com>wrote:
>
>> The problem has nothing to do with templates names.
>> I was writting <lift:showMarket.show>...</lift:showMarket.show>
>>
>> Capitalizing the first letter in the snippet's name
>> (<lift:ShowMarket.show>) solved the problem. Anyway looks like a bug =)
>>
>> Regards,
>> Sergey
>>
>>
>>
>> On Sun, Feb 1, 2009 at 7:09 PM, Sergey Andreev <andser...@gmail.com>wrote:
>>
>>> Derek,
>>> I was commenting out everything from my snippet and template but still
>>> the state was lossing between after redirect. And then i decided to change
>>> the name of the template from "index.html" to "add.html" (any other name)
>>> and it magically worked. Looks like a bug to me. Will investigate the
>>> sources further.
>>> Thanks for your help,
>>> Sergey
>>>
>>> On Fri, Jan 30, 2009 at 11:44 PM, Derek Chen-Becker <
>>> dchenbec...@gmail.com> wrote:
>>>
>>>> Right, really the same mechanism in different guises. Still, the code
>>>> that Sergey sent should work as far as I can tell...
>>>>
>>>> Derek
>>>>
>>>>
>>>> On Fri, Jan 30, 2009 at 11:01 AM, Marius <marius.dan...@gmail.com>wrote:
>>>>
>>>>>
>>>>> 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