Trait

net.liftweb.http

StatefulSnippet

Related Doc: package http

Permalink

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
Known Subclasses
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]

    Permalink
    Definition Classes
    DispatchSnippet

Abstract Value Members

  1. abstract def dispatch: DispatchIt

    Permalink
    Definition Classes
    DispatchSnippet

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def addName(name: String): Unit

    Permalink
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  11. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  12. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  13. def link(to: String, func: () ⇒ Any, body: NodeSeq, attrs: SHtml.ElemAttr*): Elem

    Permalink

    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]

    Permalink
  15. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  16. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  17. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  18. def redirectTo(where: String): Nothing

    Permalink

    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

    Permalink
  20. def seeOther(where: String): Nothing

    Permalink

    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

    Permalink
    Definition Classes
    AnyRef
  22. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  23. def unregisterThisSnippet(): Unit

    Permalink
  24. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from DispatchSnippet

Inherited from AnyRef

Inherited from Any

Ungrouped