Because this snippet is stateless. For each snippet invocation a new snippet instance is created. If you want to preserve that same snippet instance during rendering extend StatefulSnippet. Second alternative is to keep it like that and use a RequestVar to "store" the count.
Br's, Marius On Jul 21, 4:57 pm, pravin <[email protected]> wrote: > hi... > i have one snippet class called Search like this ---- > > class Search{ > private var count=0; > > // I have one method name :"fun1".In this method i am changing the > value of count(class lavel variable) > > def fun1(xhtml:NodeSeq):NodeSeq={ > count=10; > bind ("entry",xhtml, > "SerchStringLable" -> "WebApp", > "SerchStringValue" -> > SHtml.text(valueString,valueString > =_, > "submit" -> SHtml.submit("Explore",processEntry _)) > > } > > // i have second method Name:"fun2" .In this method i am accessing > same variable(count). > > def fun2(xhtml:NodeSeq):NodeSeq={ > println("Count :"+count) // this prints 0 instaed of > 10 ...why > bind("t", xhtml,"resultRows" -> buildRows) > > } > } > > //fun1 is called before fun2 > > But in fun2 ,i found default value for "count" i.e 0 > why i didnt get update value that i changed in fun1.... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---
