Packages

t

net.liftweb.http

StatefulSnippet

trait StatefulSnippet extends DispatchSnippet

The same StatefulSnippet instance is used across a given page rendering.
If the StatefulSnippet is used to render a form, a hidden field is added to the form that causes the same instance to be used on the page that is the target of the form submission.
If you want to keep the same snippet for a page rendered via a link (<a href...>) use the StatefulSnippet.link method to create the link. This will cause the registerThisSnippet method to be called and the same instance will be used on the target page.

class CountGame extends StatefulSnippet  {
 val dispatch: DispatchIt =  {
   case "run" => run _
}

 def run(xhtml: NodeSeq): NodeSeq =  {
   if (lastGuess == number)  {
     bind("count", chooseTemplate("choose", "win", xhtml), "number" --> number, "count" --> count)
} else  {
     bind("count", chooseTemplate("choose", "guess", xhtml),
       "input" --> text("", guess _),
       "last" --> lastGuess.map(v => if (v < number) v+" is low" else v+"is high").openOr("Make first Guess")
     )
}

 private def guess(in: String)  {
   count += 1
   lastGuess = Full(toInt(in))
}

 private val number = 1 + randomInt(100)
 private var lastGuess: Box[Int] = Empty
 private var count = 0

}

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. StatefulSnippet
  2. DispatchSnippet
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. type DispatchIt = PartialFunction[String, (NodeSeq) ⇒ NodeSeq]
    Definition Classes
    DispatchSnippet

Abstract Value Members

  1. abstract def dispatch: DispatchIt
    Definition Classes
    DispatchSnippet

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def addName(name: String): Unit
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  12. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  13. def link(to: String, func: () ⇒ Any, body: NodeSeq, attrs: SHtml.ElemAttr*): Elem

    create an anchor tag around a body

    create an anchor tag around a body

    to

    - the target

    func

    - the function to invoke when the link is clicked

    body

    - the NodeSeq to wrap in the anchor tag

    attrs

    - the (optional) attributes for the HTML element

  14. def names: Set[String]
  15. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  17. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  18. def redirectTo(where: String): Nothing

    Redirect to another page, but make sure this StatefulSnippet is registered on that page so the state continues on the new page

  19. def registerThisSnippet(): Unit
  20. def seeOther(where: String): Nothing

    See Other to another page, but make sure this StatefulSnippet is registered on that page so the state continues on the new page

  21. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  22. def toString(): String
    Definition Classes
    AnyRef → Any
  23. def unregisterThisSnippet(): Unit
  24. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )

Inherited from DispatchSnippet

Inherited from AnyRef

Inherited from Any

Ungrouped