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.3 built on Tue Apr 05 13:24:00 PDT 2011.
Stats: Total Memory: 494,403,584 Free Memory: 427,413,808 Open Sessions: 143
Updated At: Sat Feb 04 09:37:51 PST 2012 Started At: Thu Jul 07 11:17:57 PDT 2011