StatfulSnippet does not actually have session scope. It guarantees that for the same request you get the same snippet instance. If for some reason you still don't want a StatefulSnippet you can put your results in a RequestVar, set the value when you process the form and use it when render the page in binds.
Br's, Marius On Jun 6, 11:14 pm, Lance Walton <lance.c.wal...@googlemail.com> wrote: > Hi. > > From my various readings, I believed that a single instance of a > snippet will be used for a particular request. I am trying to make use > of this in order to implement a search feature in my app. So I have a > template that looks like this: > > <lift:surround with="default" at="content"> > <h1>Search</h1> > <lift:SearchSnippet.nameSearch form="POST"> > Name: <search:name/> <search:submit/> > </lift:SearchSnippet.nameSearch> > > <h1>Results</h1> > <div><lift:SearchSnippet.searchResults><fires:list> > <div><result:name/></div> > </fires:list></lift:SearchSnippet.searchResults></div> > </lift:surround> > > And my snippet looks like this: > > class SearchSnippet { > var results : List[Result] = List() > > def nameSearch(xhtml : NodeSeq) : NodeSeq = { > var name = "" > > def process() { > results = ... some stuff to get the results ... > } > > bind("search", xhtml, > "name" -> SHtml.text(name, name = _), > "submit" -> SHtml.submit("Search", process)) > } > > def searchResults(xhtml : NodeSeq) : NodeSeq = > results.flatMap(f => bindResult(f)(chooseTemplate("results", > "list", xhtml))) > > def bindResult(result : Result)(xhtml : NodeSeq) = > bind("result", xhtml, > "name" -> result.name) > > } > > What I expected is that when the form is submitted, an instance of > SearchSnippet will be created and 'results' will be populated. Then, > when the results sectionof the template is processed, the > 'searchResults' method can bind the results. However, I never see any > results, and a bit of debugging suggests that different instances are > in play. Is this as expected? > > I don't think I want a StatefulSnippet because that seems to have > session 'scope'. > > What to do? > > Regards, > > Lance --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---