I have "changed class Products {" to read "class Products extends StatefulSnippet {"
Instead of S.redirectTo, I now have this.redirectTo and it still doesn't seem to be saving the state. On Apr 17, 10:55 pm, Derek Chen-Becker <dchenbec...@gmail.com> wrote: > OK, first, your snippet class needs to extend StatefulSnippet. Then you need > to define the dispatch partial function to tell it which snippet goes to > which function, and then you need to use StatefulSnippet.link and > StatefulSnippet.redirectTo instead of SHtml.link and S.redirectTo, > respectievly. > > Derek > > On Fri, Apr 17, 2009 at 7:45 PM, bradford <fingerm...@gmail.com> wrote: > > > I'm trying to play around with the StatefulSnippets and can't get it > > to hold state. This is what I have for a test: > > > class Products { > > object productVar extends RequestVar(new Product()) > > def selectedProduct = productVar.is > > > def search(xhtml: Group): NodeSeq = { > > var query = ""; > > > def processSearch() = { > > // hard code id for now > > val product = Model.createNamedQuery[Product]("findProductById", > > ("id" -> 1L)).getSingleResult() > > Log.info("processSearch: " + product.id.toString) // prints 1 > > productVar(product) > > Log.info("post processSearch: " + product.id.toString) // > > prints 1 > > > S.redirectTo("select.html") > > } > > > val plAttrs = List(("size", "40"), ("maxlength", "80"), ("style", > > "width: 98%")) > > bind("f", xhtml, > > "query" -> SHtml.text(query, query = _), > > "submit" -> SHtml.submit("Search", processSearch) > > ) > > } > > > def selectedQuery(xhtml: NodeSeq): NodeSeq = { > > Log.info("selectedProduct: " + selectedProduct.id.toString) // > > HELP!: prints 0 > > Text(selectedProduct.name("en_US") match { case Some(a) => a.name > > case None => "No Product Found"}) > > } > > } --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---