I guess it would help to mention that <lift:Products.search /> is on
index.html and <lift:Products.selectedQuery /> is on select.html.

On Apr 17, 9: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
-~----------~----~----~----~------~----~------~--~---

Reply via email to