Lift Web Framework

Say Anything:

The Code

/**
 * The Arc Challenge is Paul Graham's quest for web framework concision.
 *
 * http://www.paulgraham.com/arcchallenge.html
 *
 * This is one potential lift-based solution to it using StatefulSnippets.
 * There are doubtless many other ways.
 *
 * @author: Steve Jenson
 */
class ArcChallenge extends StatefulSnippet {
  var dispatch: DispatchIt = {case _ => xhtml => ask}

  /**
   * Step 1: Type in a Phrase.
   */
  def ask = {
    <p>
    Say Anything:
    {text("", p => phrase = p)}
    {submit("Submit", () => dispatch = {case _ => xhtml => think})}
    </p>
  }

  /**
   * Step 2: Show a link that takes you to the Phrase you entered.
   */
  def think = submit("Click here to see what you said",
                     () => dispatch = {case _ => xhtml => answer})

  /**
   * Step 3: Show the phrase.
   */
  def answer = <p>You said: {phrase}</p>

  private var phrase = ""
}
  

Lift is Copyright 2007-2010 WorldWide Conferencing, LLC. Distributed under an Apache 2.0 License.
Lift version 2.1-SNAPSHOT built on Wed Sep 01 14:56:07 PDT 2010.
Stats: Total Memory: 267,976,704 Free Memory: 210,332,456 Open Sessions: 573
Updated At: Thu Sep 09 01:15:12 PDT 2010 Started At: Wed Sep 01 23:29:27 PDT 2010