Also, why can't a snippet figure out its own name? On Fri, Oct 30, 2009 at 3:38 PM, Naftoli Gugenheim <naftoli...@gmail.com>wrote:
> I think that's the source of the bug. When > LiftSession.findSnippetInstance's call to S.snippetForClass returns Empty it > calls findSnippetClass, instantiates it, adds the class name to the > snippetNames, and calls S.setSnippetForClass. Maybe setSnippetForClass > should do it automatically? > Or maybe I should do what LiftSession does and add a name manually. Then I > can either call S.setSnippetForClass or StatefulSnippet.registerThisSnippet. > > > On Fri, Oct 30, 2009 at 3:34 PM, Naftoli Gugenheim > <naftoli...@gmail.com>wrote: > >> I added the following comment: >> Adding println(names) in the submit function (even after calling >> S.setSnippetForClass) >> prints Set(). >> On the other hand if the snippet was instantiated by Lift then it prints >> as expected (in my case Set(Clients). >> >> >> On Fri, Oct 30, 2009 at 3:16 PM, Naftoli Gugenheim >> <naftoli...@gmail.com>wrote: >> >>> I'll write some code on the ticket that you should be able to stick into >>> any project to test it and if it's not good enough I'll have to create a >>> project. >>> I may as well write it here too. >>> (Not compiled) >>> >>> Put in some template: >>> <lift:MyTestSnippet /> >>> >>> Put in some other screen: >>> def test = { >>> class Test extends StatefulSnippet { >>> println("Test is now being instantiated!") >>> >>> def dispatch = { case _ => render _ } >>> def render(xhtml: NodeSeq) = SHtml.submit("Submit test", () => {} ) >>> } >>> } >>> and >>> SHtml.link("pathToFirstTemplate", () >>> => S.setSnippetForClass("MyTestSnippet", new Test), Text("A link") ) >>> >>> >>> >>> On Fri, Oct 30, 2009 at 2:53 PM, David Pollak < >>> feeder.of.the.be...@gmail.com> wrote: >>> >>>> >>>> >>>> On Fri, Oct 30, 2009 at 11:49 AM, Naftoli Gugenheim < >>>> naftoli...@gmail.com> wrote: >>>> >>>>> Do you need a complete project? >>>> >>>> >>>> I need a complete way to reproduce the problem. A whole project is the >>>> best way to do that. >>>> >>>> >>>>> >>>>> >>>>> On Fri, Oct 30, 2009 at 2:09 PM, David Pollak < >>>>> feeder.of.the.be...@gmail.com> wrote: >>>>> >>>>>> File a ticket with a code sample. >>>>>> >>>>>> >>>>>> On Fri, Oct 30, 2009 at 11:03 AM, Naftoli Gugenheim < >>>>>> naftoli...@gmail.com> wrote: >>>>>> >>>>>>> >>>>>>> Hi. I tried the new functionality. Step 1 works: In my edit client >>>>>>> link function I call S.setSnippetForClass("Clients", editSnippet) and it >>>>>>> brings up the page, using the correct snippet. >>>>>>> Now the editing page has a submit button, "Duplicate", which for >>>>>>> testing purposes I commented out its function to do nothing. When the >>>>>>> snippet has been instantiated by Lift internally, clicking Duplicate >>>>>>> correctly reuses the snippet when it reloads the page. However when the >>>>>>> snippet was pre-registered using S.setSnippetForClass, the submit button >>>>>>> causes a new snippet to be instantiated for the reload. Even >>>>>>> registerThisSnippet doesn't work -- it's necessary to call >>>>>>> setSnippetForClass in the submit function. Not that that's such a big >>>>>>> deal >>>>>>> but it's probably not the intended behavior. >>>>>>> So in short, S.setSnippetForClass works but doesn't survive a reload >>>>>>> via a submit button, nor does registerThisSnippet extend its lifetime. >>>>>>> Thanks. >>>>>>> >>>>>>> ------------------------------------- >>>>>>> David Pollak<feeder.of.the.be...@gmail.com> wrote: >>>>>>> >>>>>>> I opened a ticket for this. I'll expose functionality so you can >>>>>>> register >>>>>>> stateful snippets as part of the request process. >>>>>>> >>>>>>> On Sun, Oct 25, 2009 at 1:09 PM, Naftoli Gugenheim < >>>>>>> naftoli...@gmail.com>wrote: >>>>>>> >>>>>>> > >>>>>>> > This may be more of a feature request than a question. >>>>>>> > I generally use StatefulSnippets rather than RequestVars. I have >>>>>>> several >>>>>>> > places in my Lift webapp where one should be redirected to a screen >>>>>>> managed >>>>>>> > by a StatefulSnippet. Until recently I thought it would suffice to >>>>>>> use >>>>>>> > S.mapSnippet to map the StatefulSnippet's method as a function. >>>>>>> > However, this approach has two shortcomings: (1) If the page uses >>>>>>> multiple >>>>>>> > snippet methods it become tedious to write mapSnippet for each one. >>>>>>> (2) >>>>>>> > Since the snippet can't be registered because it can only get a >>>>>>> snippetName >>>>>>> > via private[http] API, any stateful links, redirects, or submits >>>>>>> don't work. >>>>>>> > Of course a workaround may be custom replacement methods on the >>>>>>> snippet that >>>>>>> > use multiple mapSnippets rather than registerThisSnippet, but again >>>>>>> this can >>>>>>> > become tedious. >>>>>>> > Would it be possible to create a public API either to assign a >>>>>>> snippet its >>>>>>> > name so it can be registered, or to retreive a snippet by name? Or >>>>>>> better >>>>>>> > yet, assign its name in its constructor or the first time >>>>>>> > registerThisSnippet etc. is called? >>>>>>> > >>>>>>> > > >>>>>>> > >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> Lift, the simply functional web framework http://liftweb.net >>>>>>> Beginning Scala http://www.apress.com/book/view/1430219890 >>>>>>> Follow me: http://twitter.com/dpp >>>>>>> Surf the harmonics >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Lift, the simply functional web framework http://liftweb.net >>>>>> Beginning Scala http://www.apress.com/book/view/1430219890 >>>>>> Follow me: http://twitter.com/dpp >>>>>> Surf the harmonics >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>> >>>> >>>> -- >>>> Lift, the simply functional web framework http://liftweb.net >>>> Beginning Scala http://www.apress.com/book/view/1430219890 >>>> Follow me: http://twitter.com/dpp >>>> Surf the harmonics >>>> >>>> >>>> >>>> >>> >> > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---