Browse files

Added a lot more content in chapter 1. Fixed up the master lyx file w…

…ith better

layout and things like a bibliography and index. Added a bibtex file to track
external references to articles, etc. Added in the helloworld example for
chapter 1.
  • Loading branch information...
1 parent 17f1360 commit 06c62041b6e5f4a0ed08d92f8d794d8efcb2340a @dchenbecker dchenbecker committed Sep 26, 2008
View
1 .gitignore
@@ -4,3 +4,4 @@ target/
*.class
.svn/
*~
+*.bak
View
1,228 chapter01.lyx
@@ -41,6 +41,12 @@
\begin_layout Chapter
Welcome to Lift!
+\begin_inset LatexCommand label
+name "cha:Welcome-to-Lift!"
+
+\end_inset
+
+
\end_layout
\begin_layout Standard
@@ -53,10 +59,32 @@ Exploring Lift
great framework for building compelling web applications.
Lift is designed to make powerful techniques easily accessible, while keeping
the overall framework simple and flexible.
+ It may sound like a clich
+\family roman
+\series medium
+\shape up
+\emph off
+\bar no
+\noun off
+\color none
+\family default
+\series default
+\shape default
+\emph default
+\bar default
+\noun default
+\color inherit
+, but in our experience Lift makes it fun to develop because it lets you
+ focus on the interesting parts of coding.
Our goal for this book is that by the end, you'll be able to create and
extend any web application you can think of.
\end_layout
+\begin_layout Section
+Why Lift?
+\end_layout
+
\begin_layout Standard
For those of you have experience with other web frameworks such as Struts,
Tapestry, Rails, et cetera, you must be asking yourself "Why another framework?
@@ -88,10 +116,10 @@ basic configuration
your web.xml and add one or more lines telling Lift what package your classes
sit in
\begin_inset Note Note
-status collapsed
+status open
\begin_layout Standard
-Should add a cross-reference here to the later section
+TODO: cross-ref
\end_layout
\end_inset
@@ -108,29 +136,14 @@ Should add a cross-reference here to the later section
\begin_layout Standard
One of the key strengths of Lift is the clean separation of presentation
content and logic, based on the bedrock concept of the Model-View-Controller
- pattern
-\begin_inset Foot
-status collapsed
-
-\begin_layout Standard
-More on MVC can be found at
-\begin_inset LatexCommand htmlurl
-target "http://en.wikipedia.org/wiki/Model-view-controller"
+\begin_inset LatexCommand index
+name "MVC"
\end_inset
-
-\begin_inset Note Note
-status collapsed
-
-\begin_layout Standard
-Is there a better link than Wikipedia?
-\end_layout
-
-\end_inset
-
-
-\end_layout
+ pattern
+\begin_inset LatexCommand cite
+key "Reenskaug1979"
\end_inset
@@ -141,7 +154,6 @@ Is there a better link than Wikipedia?
status collapsed
\begin_layout Standard
-The Java Server Pages home page is at
\begin_inset LatexCommand htmlurl
target "http://java.sun.com/products/jsp/"
@@ -172,9 +184,6 @@ target "http://java.sun.com/products/jsp/"
status collapsed
\begin_layout Standard
-Wicket is an interesting web framework that inspired Lift's avoidance of
- special HTML for templating.
- More info can be found on the Wicket home page:
\begin_inset LatexCommand htmlurl
target "http://wicket.apache.org/"
@@ -208,7 +217,13 @@ Not only does Scala have some extensive library support for XML, but XML
\begin_layout Standard
Lift has another advantage that no other web framework currently shares:
- the Scala programming language.
+ the Scala
+\begin_inset LatexCommand index
+name "Scala"
+
+\end_inset
+
+ programming language.
Scala is a relatively new language developed by Martin Odersky
\begin_inset Foot
status collapsed
@@ -314,13 +329,23 @@ A trait is a Scala construct that's essentially like a Java interface.
logic) into your templates.
\end_layout
+\begin_layout Section
+For more information
+\begin_inset LatexCommand label
+name "sec:For-more-information"
+
+\end_inset
+
+
+\end_layout
+
\begin_layout Standard
-One final point to note is the breadth and depth of the Lift community.
- Since its inception in 2007 the list has grown to hundreds of members from
- all over the world.
+Lift has a very active community of users and developers.
+ Since its inception in early 2007 the community has grown to hundreds of
+ members from all over the world.
The project's leader, David Pollak
\begin_inset Foot
-status open
+status collapsed
\begin_layout Standard
\begin_inset LatexCommand htmlurl
@@ -337,7 +362,1148 @@ is constantly attending to the mailing list, answering questions and taking
feature requests.
There is a core group of developers who work on the project, but submissions
are taken from anyone who makes a good case and can turn in good code.
+ While we strive to cover everything you'll need to know in this book, here
+ are several additional resources available for information on Lift:
+\end_layout
+
+\begin_layout Enumerate
+The first place to look is the Wiki at
+\begin_inset LatexCommand htmlurl
+target "http://liftweb.net/index.php/Main_Page"
+
+\end_inset
+
+.
+ The Wiki is maintained not only by David, but by many active members of
+ the Lift community (including the authors).
+ Portions of this book as inspired by and borrow from content on the Wiki.
+ In particular, it has links to all of the generated documentation not only
+ for the stable branch, but for the unstable head if you're feeling adventurous.
+ There's also an extensive section of HowTos and articles on advanced topics
+ that covers a wealth of information.
+\end_layout
+
+\begin_layout Enumerate
+The mailing list at
+\begin_inset LatexCommand htmlurl
+target "http://groups.google.com/group/liftweb"
+
+\end_inset
+
+ is very active and if there are things that this book doesn't cover you
+ can feel free to ask questions there; there are plenty of very knowledgeable
+ people on the list that should be able to answer your questions.
+ Please send specific questions about the book to ...
+\begin_inset Note Note
+status open
+
+\begin_layout Standard
+Should we set up our own google group?
+\end_layout
+
+\end_inset
+
+, but anything else Lift-specific is fair game for the mailing list.
+\end_layout
+
+\begin_layout Enumerate
+Lift has an IRC channel at
+\begin_inset LatexCommand htmlurl
+target "irc://irc.freenode.net/lift"
+
+\end_inset
+
+ that usually has several people on at any given time.
+ It's a great place to chat about issues and ideas concerning Lift.
+\end_layout
+
+\begin_layout Section
+Your first Lift application
+\end_layout
+
+\begin_layout Standard
+We've talked a lot about Lift and its capabilities, so now let's get hands-on
+ and try out an application.
+ Before we start, though, we need to take care of some prerequisites:
+\end_layout
+
+\begin_layout Description
+Java\InsetSpace ~
+1.5\InsetSpace ~
+JDK Lift runs on Scala, which runs on top of the JVM; the first thing
+ you'll need to install is a modern version of the Java SE JVM, available
+ at
+\begin_inset LatexCommand htmlurl
+target "http://java.sun.com/"
+
+\end_inset
+
+.
+ Recently Scala's compiler was changed to target Java version 1.5; 1.4 is
+ still available as a target, but we're going to assume you're using 1.5.
+ Examples in this book have only been tested with Sun's version of the JDK,
+ although most likely other versions (Blackdown, OpenJDK) should work with
+ little or no modification.
+
+\begin_inset Note Note
+status open
+
+\begin_layout Standard
+Should we include brief blurbs on platform-specific installation?
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Description
+Maven\InsetSpace ~
+2 Maven
+\begin_inset LatexCommand index
+name "Maven"
+
+\end_inset
+
+ is a project management tool which we'll cover in more detail in chapter
+
+\begin_inset LatexCommand vref
+reference "cha:Maven"
+
+\end_inset
+
+.
+ Maven has extensive capabilities for building, dependency management, testing
+ and reporting.
+ If you haven't used Maven before you can think of it as an incredibly powerful
+ version of
+\family typewriter
+make
+\family default
+ for now.
+ You can download the latest version of Maven from
+\begin_inset LatexCommand htmlurl
+target "http://maven.apache.org/"
+
+\end_inset
+
+.
+ Brief installation instructions (enough to get us started) are on the download
+ page, at
+\begin_inset LatexCommand htmlurl
+target "http://maven.apache.org/download.html"
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Description
+Programming\InsetSpace ~
+editor This isn't a strict requirement for this example, but
+ when we start getting into coding it's very helpful to have something a
+ little more capable than notepad.
+ If you'd like a full-blown IDE, with support for things like debugging,
+ continuous compile checking, etc, there are plugins available on the Scala
+ website at
+\begin_inset LatexCommand htmlurl
+target "http://www.scala-lang.org/node/91"
+
+\end_inset
+
+.
+ The plugins support:
+\end_layout
+
+\begin_deeper
+\begin_layout List
+\labelwidthstring 00.00.0000
+\begin_inset LatexCommand htmlurl
+name "Eclipse"
+target "http://www.eclipse.org/"
+
+\end_inset
+
+ The Scala plugin developer recommends using the
+\emph on
+Eclipse Classic
+\emph default
+ version of the IDE
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+\begin_inset LatexCommand htmlurl
+name "NetBeans"
+target "http://www.netbeans.org"
+
+\end_inset
+
+ Requires using the NetBeans 6.5 Beta (at the time of writing)
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+\begin_inset LatexCommand htmlurl
+name "IntelliJ IDEA"
+target "http://www.jetbrains.com/idea/index.html"
+
+\end_inset
+
+ Requires version 8 beta
+\end_layout
+
+\begin_layout Standard
+If you'd like something more lightweight, the Scala language distribution
+ comes with plugins for editors like VIM, Emacs, jedit, etc.
+ You can either download the full Scala distribution from
+\begin_inset LatexCommand htmlurl
+target "http://www.scala-lang.org/"
+
+\end_inset
+
+ and use the files under
+\family typewriter
+misc/scala-tool-support
+\family default
+, or you can directly access the latest versions via the SVN (Subversion)
+ interface at
+\begin_inset LatexCommand htmlurl
+target "https://lampsvn.epfl.ch/trac/scala/browser/scala-tool-support/trunk/src"
+
+\end_inset
+
+.
+ Getting these plugins to work in your IDE or editor of choice is beyond
+ the scope of this book.
+\end_layout
+
+\end_deeper
+\begin_layout Standard
+Now that we have the prerequisites out of the way, it's time to get started.
+ We're going to leverage Maven's archetypes
+\begin_inset Note Note
+status open
+
+\begin_layout Standard
+TODO: Need a cross-reference to the section on archetypes
+\end_layout
+
+\end_inset
+
+to do 99% of the work for us in this example.
+ First, change to whatever directory you'd like to work in:
+\end_layout
+
+\begin_layout LyX-Code
+cd work
+\end_layout
+
+\begin_layout Standard
+Next, we use Maven's
+\family typewriter
+archetype:generate
+\family default
+ command to create the skeleton of our project:
+\end_layout
+
+\begin_layout LyX-Code
+mvn archetype:generate -U
+\backslash
+
+\end_layout
+
+\begin_layout LyX-Code
+ -DarchetypeGroupId=net.liftweb
+\backslash
+
+\end_layout
+
+\begin_layout LyX-Code
+ -DarchetypeArtifactId=lift-archetype-blank
+\backslash
+
+\end_layout
+
+\begin_layout LyX-Code
+ -DarchetypeVersion=0.9
+\backslash
+
+\end_layout
+
+\begin_layout LyX-Code
+ -DremoteRepositories=http://scala-tools.org/repo-releases
+\backslash
+
+\end_layout
+
+\begin_layout LyX-Code
+ -DgroupId=demo.helloworld
+\backslash
+
+\end_layout
+
+\begin_layout LyX-Code
+ -DartifactId=helloworld
+\backslash
+
+\end_layout
+
+\begin_layout LyX-Code
+ -Dversion=1.0-SNAPSHOT
+\end_layout
+
+\begin_layout Standard
+Maven should dump several page's worth of output.
+ It may stop and ask you to confirm the properties configuration, in which
+ case you can just hit
+\family typewriter
+<enter>
+\family default
+.
+ At the end you should get a message that says
+\family typewriter
+BUILD SUCCESSFUL
+\family default
+.
+ You've now successfully created your first project! Don't believe us? Let's
+ run it to confirm:
+\end_layout
+
+\begin_layout LyX-Code
+cd helloworld
+\end_layout
+
+\begin_layout LyX-Code
+mvn jetty:run
+\end_layout
+
+\begin_layout Standard
+Maven should produce more output, ending with
+\end_layout
+
+\begin_layout LyX-Code
+[INFO] Starting scanner at interval of 5 seconds.
+\end_layout
+
+\begin_layout Standard
+This means that you now have a web server (Jetty
+\begin_inset Foot
+status collapsed
+
+\begin_layout Standard
+\begin_inset LatexCommand htmlurl
+target "http://www.mortbay.org/jetty/"
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+) running on port 8080 of your machine.
+ Just go to
+\begin_inset LatexCommand htmlurl
+target "http://localhost:8080/"
+
+\end_inset
+
+ and you'll see your first Lift page, the standard
+\begin_inset Quotes eld
+\end_inset
+
+Hello world!
+\begin_inset Quotes erd
+\end_inset
+
+.
+ With just a few simple commands we've built a functional (albeit limited)
+ web app.
+ Let's go into a little more detail and see exactly how these pieces fit
+ together.
+ First, let's examine the index page.
+ Whenever Lift serves up a request where the URL ends in a forward slash,
+ Lift automatically looks for a file called index.html
+\begin_inset Foot
+status collapsed
+
+\begin_layout Standard
+Technically, it also searches for some variations on index.html, including
+ any localized versions of the page, but we'll cover that later in section
+\begin_inset Note Note
+status open
+
+\begin_layout Standard
+TODO: Need a cross reference here
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+ in that directory.
+ For instance, if you tried to go to
+\family typewriter
+http://localhost:8080/test/
+\family default
+, Lift would look for index.html under the
+\family typewriter
+test/
+\family default
+ directory in your project.
+ The HTML sources will be located under
+\family typewriter
+src/main/webapp/
+\family default
+ in your project directory Here's the
+\family typewriter
+index.html
+\family default
+ file from our Hello World project:
+\end_layout
+
+\begin_layout Standard
+\begin_inset listings
+lstparams "basicstyle={\small\ttfamily},frame=lines,language=XML"
+inline false
+status open
+
+\begin_layout Standard
+
+<lift:surround with="default" at="content">
+\end_layout
+
+\begin_layout Standard
+
+ <h2>Welcome to your project!</h2>
+\end_layout
+
+\begin_layout Standard
+
+ <p><lift:helloWorld.howdy /></p>
+\end_layout
+
+\begin_layout Standard
+
+</lift:surround>
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+This may look a little strange at first.
+ For those with some XML experience you may recognize the use of prefixed
+ elements here.
+ For those who don't know what that is, a prefixed element is an XML element
+ of the form
+\end_layout
+
+\begin_layout LyX-Code
+<prefix:element>
+\end_layout
+
+\begin_layout Standard
+In our case we have two elements in use:
+\family typewriter
+<lift:surround>
+\family default
+ and
+\family typewriter
+<lift:helloWorld.howdy/>
+\family default
+.
+ Lift assigns special meaning to elements that use the
+\begin_inset Quotes eld
+\end_inset
+
+lift
+\begin_inset Quotes erd
+\end_inset
+
+ prefix; they form the basis of lift's extensive templating support, which
+ we will cover in more detail in
+\begin_inset Note Note
+status open
+
+\begin_layout Standard
+TODO: Need a cross reference here
+\end_layout
+
+\end_inset
+
+.
+ When lift processes an XML template
+\begin_inset LatexCommand index
+name "template"
+
+\end_inset
+
+, it does so from the outermost element inward.
+ In our case, the outermost element is
+\family typewriter
+<lift:surround with=
+\begin_inset Quotes erd
+\end_inset
+
+default
+\begin_inset Quotes erd
+\end_inset
+
+ at=
+\begin_inset Quotes erd
+\end_inset
+
+content
+\begin_inset Quotes erd
+\end_inset
+
+>
+\family default
+.
+ The
+\family typewriter
+<lift:surround>
+\family default
+ element basically tells Lift to find the template named by the
+\emph on
+with
+\emph default
+ attribute (
+\emph on
+default
+\emph default
+, in our case) and to put the contents of our element inside of that template.
+ The
+\emph on
+at
+\emph default
+ attribute tells Lift where in the template to place our content.
+ In Lift, this
+\begin_inset Quotes eld
+\end_inset
+
+filling in the blanks
+\begin_inset Quotes erd
+\end_inset
+
+ is called
+\emph on
+binding
+\emph default
+
+\begin_inset LatexCommand index
+name "binding"
+
+\end_inset
+
+, and it's a fundamental concept of Lift's template system.
+ Just about everything at the HTML/XML level can be thought of as a series
+ of nested binds.
+ Before we move on to the
+\family typewriter
+<lift:helloWorld.howdy/>
+\family default
+ element, let's recurse and look at the default template.
+ You can find it in the
+\family typewriter
+templates-hidden
+\family default
+ directory of the web app.
+ Much like the
+\family typewriter
+WEB-INF
+\family default
+ and
+\family typewriter
+META-INF
+\family default
+ directories in a Java web application, the contents of
+\family typewriter
+templates-hidden
+\family default
+ cannot be accessed directly by clients; they can, however be accessed when
+ they're referenced by a
+\family typewriter
+<lift:surround>
+\family default
+ element.
+ Here is the
+\family typewriter
+default.html
+\family default
+ file:
+\end_layout
+
+\begin_layout Standard
+\begin_inset listings
+lstparams "basicstyle={\scriptsize},breaklines=true,frame=lines,language=XML"
+inline false
+status open
+
+\begin_layout Standard
+
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:lift="http://liftweb.net/">
+\end_layout
+
+\begin_layout Standard
+
+ <head>
+\end_layout
+
+\begin_layout Standard
+
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+\end_layout
+
+\begin_layout Standard
+
+ <meta name="description" content="" />
+\end_layout
+
+\begin_layout Standard
+
+ <meta name="keywords" content="" />
+\end_layout
+
+\begin_layout Standard
+
+
+\end_layout
+
+\begin_layout Standard
+
+ <title>demo.helloworld:helloworld:1.0-SNAPSHOT</title>
+\end_layout
+
+\begin_layout Standard
+
+ <script id="jquery" src="/classpath/jquery.js" type="text/javascript"></scrip
+t>
+\end_layout
+
+\begin_layout Standard
+
+ </head>
+\end_layout
+
+\begin_layout Standard
+
+ <body>
+\end_layout
+
+\begin_layout Standard
+
+ <lift:bind name="content" />
+\end_layout
+
+\begin_layout Standard
+
+ <lift:Menu.builder />
+\end_layout
+
+\begin_layout Standard
+
+ <lift:msgs/>
+\end_layout
+
+\begin_layout Standard
+
+ </body>
+\end_layout
+
+\begin_layout Standard
+
+</html>
+\end_layout
+
+\begin_layout Standard
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+As you can see in the listing, this is a proper XHTML file, with
+\family typewriter
+<html>
+\family default
+,
+\family typewriter
+<head>
+\family default
+, and
+\family typewriter
+<body>
+\family default
+ tags.
+ This is required since Lift doesn't add these itself; Lift simply processes
+ the XML from each template it encounters.
+ The
+\family typewriter
+<head>
+\family default
+ element and its contents are boilerplate; the interesting things happen
+ inside the
+\family typewriter
+<body>
+\family default
+ element.
+ There are three elements here:
+\end_layout
+
+\begin_layout Enumerate
+The
+\family typewriter
+<lift:bind name=
+\begin_inset Quotes erd
+\end_inset
+
+content
+\begin_inset Quotes erd
+\end_inset
+
+ />
+\family default
+ element determines where the contents of our index.html file are bound (inserted
+).
+ The
+\emph on
+name
+\emph default
+ attribute should match the corresponding
+\emph on
+at
+\emph default
+ attribute from our
+\family typewriter
+<lift:surround>
+\family default
+ element.
+\end_layout
+
+\begin_layout Enumerate
+The
+\family typewriter
+<lift:Menu.builder />
+\family default
+ element is a special element that builds a menu based on the SiteMap
+\begin_inset LatexCommand index
+name "SiteMap"
+
+\end_inset
+
+ (to be covered in
+\begin_inset Note Note
+status open
+
+\begin_layout Standard
+TODO: Cross ref
+\end_layout
+
+\end_inset
+
+).
+ The SiteMap is a high-level site directory component that not only provides
+ a centralized place to define a site menu, but allows you to control when
+ certain links are displayed (based on, say, whether a user is logged in
+ or what roles they have) and provides a page-level access control mechanism.
+\end_layout
+
+\begin_layout Enumerate
+The
+\family typewriter
+<lift:msgs/>
+\family default
+ element allows Lift (or your code) to display messages on a page as it's
+ rendered.
+ These could be status messages, error messages, etc.
+ Lift has facilities to set one or more messages from inside your logic
+ code.
+\end_layout
+
+\begin_layout Standard
+Now let's look back at the
+\family typewriter
+<lift:helloWorld.howdy/>
+\family default
+ element from the
+\family typewriter
+index.html
+\family default
+ file.
+ This element (and the
+\family typewriter
+<lift:Menu.builder />
+\family default
+ element, actually) is called a
+\emph on
+snippet
+\emph default
+, and it's of the form
+\end_layout
+
+\begin_layout LyX-Code
+<lift:class.method>
+\end_layout
+
+\begin_layout Standard
+Where
+\family typewriter
+class
+\family default
+ is the name of a Scala class defined in our project in the
+\family typewriter
+demo.helloworld.snippets
+\family default
+ package and
+\family typewriter
+method
+\family default
+ is a method defined on that class.
+ Lift does a little translation on the class name to change camel-case back
+ into title-case and then locates the class.
+ In our demo the class is located under
+\family typewriter
+src/main/scala/demo/helloworld/snippet/HelloWorld.scala
+\family default
+, and is shown here:
+\end_layout
+
+\begin_layout Standard
+\begin_inset listings
+lstparams "basicstyle={\scriptsize},frame=lines"
+inline false
+status open
+
+\begin_layout Standard
+
+package demo.helloworld.snippet
+\end_layout
+
+\begin_layout Standard
+
+\end_layout
+
+\begin_layout Standard
+
+class HelloWorld {
+\end_layout
+
+\begin_layout Standard
+
+ def howdy = <span>Welcome to helloworld at {new java.util.Date}</span>
+\end_layout
+
+\begin_layout Standard
+
+}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+As you can see, the howdy method is pretty straightforward.
+ Lift binds the result of executing the method into the location of the
+ snippet element (in this case a span).
+ It's interesting to note that a method may itself return other
+\family typewriter
+<lift:...>
+\family default
+ elements in its content and they will be processed as well.
+ This recursive nature of template composition is part of the fundamental
+ power of Lift; it means that reusing snippets and template pieces across
+ your application is essentially free.
+ You should never have to write the same functionality more than once.
+\end_layout
+
+\begin_layout Standard
+Now that we've covered all of the actual content elements, the final piece
+ of the puzzle is the
+\family typewriter
+Boot
+\begin_inset LatexCommand index
+name "Boot"
+
+\end_inset
+
+
+\family default
+ class.
+ The
+\family typewriter
+Boot
+\family default
+ class is responsible for the configuration and setup of the Lift framework.
+ As we've stated earlier in the chapter, most of Lift has sensible defaults,
+ so the
+\family typewriter
+Boot
+\family default
+ class generally contains only the extras that you need.
+ The
+\family typewriter
+Boot
+\family default
+ class is always located in the
+\family typewriter
+bootstrap.liftweb
+\family default
+ package and is shown here (we've skipped imports, etc):
+\end_layout
+
+\begin_layout Standard
+\begin_inset listings
+lstparams "basicstyle={\scriptsize},firstline=13,frame=lines"
+inline false
+status open
+
+\begin_layout Standard
+
+package bootstrap.liftweb
+\end_layout
+
+\begin_layout Standard
+
+\end_layout
+
+\begin_layout Standard
+
+import net.liftweb.util._
+\end_layout
+
+\begin_layout Standard
+
+import net.liftweb.http._
+\end_layout
+
+\begin_layout Standard
+
+import net.liftweb.sitemap._
+\end_layout
+
+\begin_layout Standard
+
+import net.liftweb.sitemap.Loc._
+\end_layout
+
+\begin_layout Standard
+
+import Helpers._
+\end_layout
+
+\begin_layout Standard
+
+
+\end_layout
+
+\begin_layout Standard
+
+/**
+\end_layout
+
+\begin_layout Standard
+
+ * A class that's instantiated early and run.
+ It allows the application
+\end_layout
+
+\begin_layout Standard
+
+ * to modify lift's environment
+\end_layout
+
+\begin_layout Standard
+
+ */
+\end_layout
+
+\begin_layout Standard
+
+class Boot {
+\end_layout
+
+\begin_layout Standard
+
+ def boot {
+\end_layout
+
+\begin_layout Standard
+
+ // where to search snippet
+\end_layout
+
+\begin_layout Standard
+
+ LiftRules.addToPackages("demo.helloworld")
+\end_layout
+
+\begin_layout Standard
+
+\end_layout
+
+\begin_layout Standard
+
+ // Build SiteMap
+\end_layout
+
+\begin_layout Standard
+
+ val entries = Menu(Loc("Home", "/", "Home")) :: Nil
+\end_layout
+
+\begin_layout Standard
+
+ LiftRules.setSiteMap(SiteMap(entries:_*))
+\end_layout
+
+\begin_layout Standard
+
+ }
+\end_layout
+
+\begin_layout Standard
+
+}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+There are two basic configuration elements, placed in the
+\family typewriter
+boot
+\family default
+method.
+ The first is the
+\family typewriter
+LiftRules.addToPackages
+\family default
+ method.
+ It tells lift to base its searches in the
+\family typewriter
+demo.helloworld
+\family default
+ package.
+ That means that snippets would be located in the
+\family typewriter
+demo.helloworld.snippets
+\family default
+ package, views (which we'll cover in
+\begin_inset Note Note
+status collapsed
+
+\begin_layout Standard
+TODO: Cross-ref
+\end_layout
+
+\end_inset
+
+) would be located in the
+\family typewriter
+demo.helloworld.views
+\family default
+ package, etc.
+ If you have more than one hierarchy (multiple packages) you can just call
+
+\family typewriter
+addToPackages
+\family default
+ multiple times.
+ The second item in the Boot class is the SiteMenu setup.
+ Obviously this is a pretty simple menu in this demo, but we'll cover more
+ interesting examples in
+\begin_inset Note Note
+status collapsed
+
+\begin_layout Standard
+TODO: Cross-ref
+\end_layout
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Standard
+Now that we've covered a basic example we hope you're beginning to see why
+ Lift is so powerful and cna make you more productive.
+ We've barely scratched the surface on Lift's templating and binding capabilitie
+s, but what we've shown here is already a big step.
+ In roughly 10 lines of Scala code and about 30 in XML we have a functional
+ site.
+ If we wanted to add more pages we've already got our default template set
+ up so we don't need to write the same boilerplate HTML over and over.
+ In our example we're directly generating the content for our
+\family typewriter
+helloWorld.howdy
+\family default
+ snippet, but in later examples we'll show just how easy it is to actually
+ pull content
+\emph on
+from the template itself
+\emph default
+ into the snippet and modify it as needed.
+\end_layout
+
+\begin_layout Standard
+In the following chapters we'll be covering
+\end_layout
+
+\begin_layout Itemize
+Much more complex templating and snippet binding, including input forms
+ and programmatic template selection
+\end_layout
+
+\begin_layout Itemize
+How to use SiteMap and its ancillary classes to provide a context-aware
+ site menu and access control layer
+\end_layout
+
+\begin_layout Itemize
+How to handle state within your application
+\end_layout
+
+\begin_layout Itemize
+Lift's ORM layer,
+\begin_inset Note Note
+status open
+
+\begin_layout Standard
+TODO: Record or Mapper?
+\end_layout
+
+\end_inset
+
+ which provides a powerful yet lightweight interface to databases
+\end_layout
+
+\begin_layout Itemize
+Advanced AJAX and COMET support in Lift for Web 2.0 style applications
+\end_layout
+
+\begin_layout Itemize
+Deployment on a range of platforms
+\end_layout
+
+\begin_layout Standard
+We hope you're as excited about getting started with Lift as we are!
\end_layout
\end_body
View
52 chapter02.lyx
@@ -40,7 +40,19 @@
\begin_body
\begin_layout Chapter
-Getting to know Maven and Project Layout
+Getting to know Maven
+\begin_inset LatexCommand index
+name "Maven"
+
+\end_inset
+
+ and Project Layout
+\begin_inset LatexCommand label
+name "cha:Maven"
+
+\end_inset
+
+
\end_layout
\begin_layout Itemize
@@ -88,7 +100,13 @@ target "http://maven.apache.org/"
\end_inset
.
- Maven is a project management tool that is developed under the Apache Software
+ Maven
+\begin_inset LatexCommand index
+name "Maven"
+
+\end_inset
+
+ is a project management tool that is developed under the Apache Software
Foundation
\begin_inset Foot
status collapsed
@@ -119,7 +137,17 @@ At the beginning of your development your interaction with Maven will be
\family typewriter
mvn -U clean jetty:run
\family default
- repeatedly.
+ repeatedly
+\begin_inset Note Note
+status open
+
+\begin_layout Standard
+Maybe we should mention the scala:cc target for continuous compilation?
+\end_layout
+
+\end_inset
+
+.
When you issue
\family typewriter
mvn -U clean jetty:run
@@ -153,9 +181,25 @@ target "http://localhost:8080/"
JARs, you'll have to spend a bit of time in the
\family typewriter
pom.xml
+\begin_inset LatexCommand index
+name "pom.xml"
+
+\end_inset
+
+
\family default
file.
- We'll get into that later in the book [WHEN?].
+ We'll get into that later in the book
+\begin_inset Note Note
+status open
+
+\begin_layout Standard
+WHEN?
+\end_layout
+
+\end_inset
+
+.
If you'd like more information about the details of Maven, please check
\family typewriter
View
133 chapter12.lyx
@@ -1,4 +1,4 @@
-#LyX 1.5.6 created this file. For more info see http://www.lyx.org/
+#LyX 1.5.3 created this file. For more info see http://www.lyx.org/
\lyxformat 276
\begin_document
\begin_header
@@ -40,135 +40,16 @@
\begin_body
\begin_layout Chapter
-AJAX and COMET
+AJAX and COMET in Depth
\end_layout
-\begin_layout Standard
-AJAX and COMET in Lift
+\begin_layout Itemize
+This is probably the place for the Spreadsheet example
\end_layout
-\begin_layout Standard
-* What is AJAX? http://en.wikipedia.org/wiki/Ajax_(programming)
-\end_layout
-
-\begin_layout Standard
-AJAX (asynchronous JavaScript and XML) is a group of techniques that allow
- for interactive web applications.
- Using AJAX applications can talk to the server asynchronously and therefore
- not disrupt the display of the client.
- (this is awkward)
-\end_layout
-
-\begin_layout Standard
-* why is AJAX awesome? [example]
-\end_layout
-
-\begin_layout Standard
-Ajax allows for a much richer interface for a web application, and example
- is Google Suggest.
- When you start typing your search term, the word fragment is sent to the
- server and common completions of your term are sent back.
-\end_layout
-
-\begin_layout Standard
-* Method for async updates pulled from the client without a full page reload
-
-\end_layout
-
-\begin_layout Standard
-* Relies heavily on javascript and XML
-\end_layout
-
-\begin_layout Standard
-* Javascript client-side events (button push, timer, etc) trigger requests
- "behind the scenes"
-\end_layout
-
-\begin_layout Standard
-* Web 2.0 built on this
-\end_layout
-
-\begin_layout Standard
-* Using AJAX in Lift
-\end_layout
-
-\begin_layout Standard
-* Allows you to bind Javascript events (AJAX) to form elements, links, etc
-
-\end_layout
-
-\begin_layout Standard
-* Go through example HelloDarwin AJAX example
-\end_layout
-
-\begin_layout Standard
-* What is COMET? http://en.wikipedia.org/wiki/Comet_(programming)
-\end_layout
-
-\begin_layout Standard
-Comet is a method that uses long-polling to keep a connection between a
- browser and a server open, to allow the server to push data to the browser.
- An example of this would be a Stock Ticker.
- A user may have a page open that has a number of stock prices and as the
- price changes, the new value is pushed to the broswer without the need
- to refresh the page.
- Another example is the embedded Google Talk chat client in GMail.
- Instant messages from friends are automatically pushed to your browser.
-\end_layout
-
-\begin_layout Standard
-* Push to the browser
-\end_layout
-
-\begin_layout Standard
-* [Example] following a LiveBlog of a keynote presentation, elememts are
- pushed to your browser
-\end_layout
-
-\begin_layout Standard
-* Here's a super simple example - http://wiki.liftweb.net/index.php/CometActor
-
-\end_layout
-
-\begin_layout Standard
-* Method for async updates pushed
-\end_layout
-
-\begin_layout Standard
-*from server to client*
-\end_layout
-
-\begin_layout Standard
-* Connection is kept open
-\end_layout
-
-\begin_layout Standard
-* Streaming
-\end_layout
-
-\begin_layout Standard
-* Long polling
-\end_layout
-
-\begin_layout Standard
-* Scalability issues
-\end_layout
-
-\begin_layout Standard
-* Using COMET in Lift
-\end_layout
-
-\begin_layout Standard
-* CometActor
-\end_layout
-
-\begin_layout Standard
-* Mine Jorge's blog post: http://scala-blogs.org/2007/12/dynamic-web-applications
--with-lift-and.html
-\end_layout
-
-\begin_layout Standard
-* Go through Dynamic chat room example
+\begin_layout Itemize
+Talk about design "patterns" ex.
+ the proper TagCloud example
\end_layout
\end_body
View
139 chapter13.lyx
@@ -1,4 +1,4 @@
-#LyX 1.5.6 created this file. For more info see http://www.lyx.org/
+#LyX 1.5.3 created this file. For more info see http://www.lyx.org/
\lyxformat 276
\begin_document
\begin_header
@@ -40,135 +40,122 @@
\begin_body
\begin_layout Chapter
-AJAX and COMET
+JPA Integration
\end_layout
-\begin_layout Standard
-AJAX and COMET in Lift
+\begin_layout Itemize
+What is JPA?
\end_layout
-\begin_layout Standard
-* What is AJAX? http://en.wikipedia.org/wiki/Ajax_(programming)
+\begin_deeper
+\begin_layout Itemize
+Part of EJB3 spec
\end_layout
-\begin_layout Standard
-AJAX (asynchronous JavaScript and XML) is a group of techniques that allow
- for interactive web applications.
- Using AJAX applications can talk to the server asynchronously and therefore
- not disrupt the display of the client.
- (this is awkward)
+\begin_layout Itemize
+Evolution of container-managed persistence
\end_layout
-\begin_layout Standard
-* why is AJAX awesome? [example]
+\begin_layout Itemize
+Simplified model (a lot less XML)
\end_layout
-\begin_layout Standard
-Ajax allows for a much richer interface for a web application, and example
- is Google Suggest.
- When you start typing your search term, the word fragment is sent to the
- server and common completions of your term are sent back.
+\begin_layout Itemize
+Heavy use of annotations, although you can define/override via XML descriptors
+ if you want
\end_layout
-\begin_layout Standard
-* Method for async updates pulled from the client without a full page reload
-
+\begin_layout Itemize
+Available in container and outside of container (Hibernate EM, JPOX, etc)
\end_layout
-\begin_layout Standard
-* Relies heavily on javascript and XML
+\end_deeper
+\begin_layout Itemize
+Why use JPA when we have mapper?
\end_layout
-\begin_layout Standard
-* Javascript client-side events (button push, timer, etc) trigger requests
- "behind the scenes"
+\begin_deeper
+\begin_layout Itemize
+Usable outside of Lift
\end_layout
-\begin_layout Standard
-* Web 2.0 built on this
+\begin_layout Itemize
+Easily accessible from Java and Scala
\end_layout
-\begin_layout Standard
-* Using AJAX in Lift
+\begin_layout Itemize
+Legacy models
\end_layout
-\begin_layout Standard
-* Allows you to bind Javascript events (AJAX) to form elements, links, etc
-
+\begin_layout Itemize
+More flexibility w/large schemas
\end_layout
-\begin_layout Standard
-* Go through example HelloDarwin AJAX example
+\begin_layout Itemize
+Performance/Caching
\end_layout
-\begin_layout Standard
-* What is COMET? http://en.wikipedia.org/wiki/Comet_(programming)
+\begin_layout Itemize
+Not mutually exclusive (Record adapter possibly?)
\end_layout
-\begin_layout Standard
-Comet is a method that uses long-polling to keep a connection between a
- browser and a server open, to allow the server to push data to the browser.
- An example of this would be a Stock Ticker.
- A user may have a page open that has a number of stock prices and as the
- price changes, the new value is pushed to the broswer without the need
- to refresh the page.
- Another example is the embedded Google Talk chat client in GMail.
- Instant messages from friends are automatically pushed to your browser.
+\end_deeper
+\begin_layout Itemize
+Intro to JPA
\end_layout
-\begin_layout Standard
-* Push to the browser
+\begin_deeper
+\begin_layout Itemize
+JPA archetype in Maven
\end_layout
-\begin_layout Standard
-* [Example] following a LiveBlog of a keynote presentation, elememts are
- pushed to your browser
+\begin_layout Itemize
+Annotations on Scala classes
\end_layout
-\begin_layout Standard
-* Here's a super simple example - http://wiki.liftweb.net/index.php/CometActor
-
+\begin_layout Itemize
+Using orm.xml to override and define
\end_layout
-\begin_layout Standard
-* Method for async updates pushed
+\end_deeper
+\begin_layout Itemize
+Getting a per-session entity manager
\end_layout
-\begin_layout Standard
-*from server to client*
+\begin_deeper
+\begin_layout Itemize
+RequestVar lifecycle
\end_layout
-\begin_layout Standard
-* Connection is kept open
+\begin_layout Itemize
+In a container (JTA)
\end_layout
-\begin_layout Standard
-* Streaming
+\begin_layout Itemize
+User-managed transactions
\end_layout
-\begin_layout Standard
-* Long polling
+\end_deeper
+\begin_layout Itemize
+ScalaEntityManager and ScalaQuery
\end_layout
-\begin_layout Standard
-* Scalability issues
+\begin_deeper
+\begin_layout Itemize
+Provide Scala-esque access to all EM methods (List vs java.util.List,etc)
\end_layout
-\begin_layout Standard
-* Using COMET in Lift
+\begin_layout Itemize
+Implicit defs for conversion from java.util.{Set,List} to Scala counterparts
\end_layout
-\begin_layout Standard
-* CometActor
+\end_deeper
+\begin_layout Itemize
+Example app (Library catalog)
\end_layout
\begin_layout Standard
-* Mine Jorge's blog post: http://scala-blogs.org/2007/12/dynamic-web-applications
--with-lift-and.html
-\end_layout
-\begin_layout Standard
-* Go through Dynamic chat room example
\end_layout
\end_body
View
126 chapter14.lyx
@@ -1,4 +1,4 @@
-#LyX 1.5.6 created this file. For more info see http://www.lyx.org/
+#LyX 1.5.3 created this file. For more info see http://www.lyx.org/
\lyxformat 276
\begin_document
\begin_header
@@ -40,135 +40,15 @@
\begin_body
\begin_layout Chapter
-AJAX and COMET
+Using Scala Actors
\end_layout
\begin_layout Standard
-AJAX and COMET in Lift
+This is a broad topic, ask the committor list for opinions
\end_layout
\begin_layout Standard
-* What is AJAX? http://en.wikipedia.org/wiki/Ajax_(programming)
-\end_layout
-
-\begin_layout Standard
-AJAX (asynchronous JavaScript and XML) is a group of techniques that allow
- for interactive web applications.
- Using AJAX applications can talk to the server asynchronously and therefore
- not disrupt the display of the client.
- (this is awkward)
-\end_layout
-
-\begin_layout Standard
-* why is AJAX awesome? [example]
-\end_layout
-
-\begin_layout Standard
-Ajax allows for a much richer interface for a web application, and example
- is Google Suggest.
- When you start typing your search term, the word fragment is sent to the
- server and common completions of your term are sent back.
-\end_layout
-
-\begin_layout Standard
-* Method for async updates pulled from the client without a full page reload
-
-\end_layout
-
-\begin_layout Standard
-* Relies heavily on javascript and XML
-\end_layout
-
-\begin_layout Standard
-* Javascript client-side events (button push, timer, etc) trigger requests
- "behind the scenes"
-\end_layout
-
-\begin_layout Standard
-* Web 2.0 built on this
-\end_layout
-
-\begin_layout Standard
-* Using AJAX in Lift
-\end_layout
-
-\begin_layout Standard
-* Allows you to bind Javascript events (AJAX) to form elements, links, etc
-
-\end_layout
-
-\begin_layout Standard
-* Go through example HelloDarwin AJAX example
-\end_layout
-
-\begin_layout Standard
-* What is COMET? http://en.wikipedia.org/wiki/Comet_(programming)
-\end_layout
-
-\begin_layout Standard
-Comet is a method that uses long-polling to keep a connection between a
- browser and a server open, to allow the server to push data to the browser.
- An example of this would be a Stock Ticker.
- A user may have a page open that has a number of stock prices and as the
- price changes, the new value is pushed to the broswer without the need
- to refresh the page.
- Another example is the embedded Google Talk chat client in GMail.
- Instant messages from friends are automatically pushed to your browser.
-\end_layout
-\begin_layout Standard
-* Push to the browser
-\end_layout
-
-\begin_layout Standard
-* [Example] following a LiveBlog of a keynote presentation, elememts are
- pushed to your browser
-\end_layout
-
-\begin_layout Standard
-* Here's a super simple example - http://wiki.liftweb.net/index.php/CometActor
-
-\end_layout
-
-\begin_layout Standard
-* Method for async updates pushed
-\end_layout
-
-\begin_layout Standard
-*from server to client*
-\end_layout
-
-\begin_layout Standard
-* Connection is kept open
-\end_layout
-
-\begin_layout Standard
-* Streaming
-\end_layout
-
-\begin_layout Standard
-* Long polling
-\end_layout
-
-\begin_layout Standard
-* Scalability issues
-\end_layout
-
-\begin_layout Standard
-* Using COMET in Lift
-\end_layout
-
-\begin_layout Standard
-* CometActor
-\end_layout
-
-\begin_layout Standard
-* Mine Jorge's blog post: http://scala-blogs.org/2007/12/dynamic-web-applications
--with-lift-and.html
-\end_layout
-
-\begin_layout Standard
-* Go through Dynamic chat room example
\end_layout
\end_body
View
128 chapter15.lyx
@@ -1,4 +1,4 @@
-#LyX 1.5.6 created this file. For more info see http://www.lyx.org/
+#LyX 1.5.3 created this file. For more info see http://www.lyx.org/
\lyxformat 276
\begin_document
\begin_header
@@ -40,135 +40,11 @@
\begin_body
\begin_layout Chapter
-AJAX and COMET
+OpenID Integration
\end_layout
\begin_layout Standard
-AJAX and COMET in Lift
-\end_layout
-
-\begin_layout Standard
-* What is AJAX? http://en.wikipedia.org/wiki/Ajax_(programming)
-\end_layout
-
-\begin_layout Standard
-AJAX (asynchronous JavaScript and XML) is a group of techniques that allow
- for interactive web applications.
- Using AJAX applications can talk to the server asynchronously and therefore
- not disrupt the display of the client.
- (this is awkward)
-\end_layout
-
-\begin_layout Standard
-* why is AJAX awesome? [example]
-\end_layout
-\begin_layout Standard
-Ajax allows for a much richer interface for a web application, and example
- is Google Suggest.
- When you start typing your search term, the word fragment is sent to the
- server and common completions of your term are sent back.
-\end_layout
-
-\begin_layout Standard
-* Method for async updates pulled from the client without a full page reload
-
-\end_layout
-
-\begin_layout Standard
-* Relies heavily on javascript and XML
-\end_layout
-
-\begin_layout Standard
-* Javascript client-side events (button push, timer, etc) trigger requests
- "behind the scenes"
-\end_layout
-
-\begin_layout Standard
-* Web 2.0 built on this
-\end_layout
-
-\begin_layout Standard
-* Using AJAX in Lift
-\end_layout
-
-\begin_layout Standard
-* Allows you to bind Javascript events (AJAX) to form elements, links, etc
-
-\end_layout
-
-\begin_layout Standard
-* Go through example HelloDarwin AJAX example
-\end_layout
-
-\begin_layout Standard
-* What is COMET? http://en.wikipedia.org/wiki/Comet_(programming)
-\end_layout
-
-\begin_layout Standard
-Comet is a method that uses long-polling to keep a connection between a
- browser and a server open, to allow the server to push data to the browser.
- An example of this would be a Stock Ticker.
- A user may have a page open that has a number of stock prices and as the
- price changes, the new value is pushed to the broswer without the need
- to refresh the page.
- Another example is the embedded Google Talk chat client in GMail.
- Instant messages from friends are automatically pushed to your browser.
-\end_layout
-
-\begin_layout Standard
-* Push to the browser
-\end_layout
-
-\begin_layout Standard
-* [Example] following a LiveBlog of a keynote presentation, elememts are
- pushed to your browser
-\end_layout
-
-\begin_layout Standard
-* Here's a super simple example - http://wiki.liftweb.net/index.php/CometActor
-
-\end_layout
-
-\begin_layout Standard
-* Method for async updates pushed
-\end_layout
-
-\begin_layout Standard
-*from server to client*
-\end_layout
-
-\begin_layout Standard
-* Connection is kept open
-\end_layout
-
-\begin_layout Standard
-* Streaming
-\end_layout
-
-\begin_layout Standard
-* Long polling
-\end_layout
-
-\begin_layout Standard
-* Scalability issues
-\end_layout
-
-\begin_layout Standard
-* Using COMET in Lift
-\end_layout
-
-\begin_layout Standard
-* CometActor
-\end_layout
-
-\begin_layout Standard
-* Mine Jorge's blog post: http://scala-blogs.org/2007/12/dynamic-web-applications
--with-lift-and.html
-\end_layout
-
-\begin_layout Standard
-* Go through Dynamic chat room example
\end_layout
\end_body
View
128 chapter16.lyx
@@ -1,4 +1,4 @@
-#LyX 1.5.6 created this file. For more info see http://www.lyx.org/
+#LyX 1.5.3 created this file. For more info see http://www.lyx.org/
\lyxformat 276
\begin_document
\begin_header
@@ -40,135 +40,11 @@
\begin_body
\begin_layout Chapter
-AJAX and COMET
+Lucene/Compass Integration
\end_layout
\begin_layout Standard
-AJAX and COMET in Lift
-\end_layout
-
-\begin_layout Standard
-* What is AJAX? http://en.wikipedia.org/wiki/Ajax_(programming)
-\end_layout
-
-\begin_layout Standard
-AJAX (asynchronous JavaScript and XML) is a group of techniques that allow
- for interactive web applications.
- Using AJAX applications can talk to the server asynchronously and therefore
- not disrupt the display of the client.
- (this is awkward)
-\end_layout
-
-\begin_layout Standard
-* why is AJAX awesome? [example]
-\end_layout
-\begin_layout Standard
-Ajax allows for a much richer interface for a web application, and example
- is Google Suggest.
- When you start typing your search term, the word fragment is sent to the
- server and common completions of your term are sent back.
-\end_layout
-
-\begin_layout Standard
-* Method for async updates pulled from the client without a full page reload
-
-\end_layout
-
-\begin_layout Standard
-* Relies heavily on javascript and XML
-\end_layout
-
-\begin_layout Standard
-* Javascript client-side events (button push, timer, etc) trigger requests
- "behind the scenes"
-\end_layout
-
-\begin_layout Standard
-* Web 2.0 built on this
-\end_layout
-
-\begin_layout Standard
-* Using AJAX in Lift
-\end_layout
-
-\begin_layout Standard
-* Allows you to bind Javascript events (AJAX) to form elements, links, etc
-
-\end_layout
-
-\begin_layout Standard
-* Go through example HelloDarwin AJAX example
-\end_layout
-
-\begin_layout Standard
-* What is COMET? http://en.wikipedia.org/wiki/Comet_(programming)
-\end_layout
-
-\begin_layout Standard
-Comet is a method that uses long-polling to keep a connection between a
- browser and a server open, to allow the server to push data to the browser.
- An example of this would be a Stock Ticker.
- A user may have a page open that has a number of stock prices and as the
- price changes, the new value is pushed to the broswer without the need
- to refresh the page.
- Another example is the embedded Google Talk chat client in GMail.
- Instant messages from friends are automatically pushed to your browser.
-\end_layout
-
-\begin_layout Standard
-* Push to the browser
-\end_layout
-
-\begin_layout Standard
-* [Example] following a LiveBlog of a keynote presentation, elememts are
- pushed to your browser
-\end_layout
-
-\begin_layout Standard
-* Here's a super simple example - http://wiki.liftweb.net/index.php/CometActor
-
-\end_layout
-
-\begin_layout Standard
-* Method for async updates pushed
-\end_layout
-
-\begin_layout Standard
-*from server to client*
-\end_layout
-
-\begin_layout Standard
-* Connection is kept open
-\end_layout
-
-\begin_layout Standard
-* Streaming
-\end_layout
-
-\begin_layout Standard
-* Long polling
-\end_layout
-
-\begin_layout Standard
-* Scalability issues
-\end_layout
-
-\begin_layout Standard
-* Using COMET in Lift
-\end_layout
-
-\begin_layout Standard
-* CometActor
-\end_layout
-
-\begin_layout Standard
-* Mine Jorge's blog post: http://scala-blogs.org/2007/12/dynamic-web-applications
--with-lift-and.html
-\end_layout
-
-\begin_layout Standard
-* Go through Dynamic chat room example
\end_layout
\end_body
View
126 chapter17.lyx
@@ -1,4 +1,4 @@
-#LyX 1.5.6 created this file. For more info see http://www.lyx.org/
+#LyX 1.5.3 created this file. For more info see http://www.lyx.org/
\lyxformat 276
\begin_document
\begin_header
@@ -40,135 +40,15 @@
\begin_body
\begin_layout Chapter
-AJAX and COMET
+Tagging Support
\end_layout
\begin_layout Standard
-AJAX and COMET in Lift
+Tyler has lots of code for this
\end_layout
\begin_layout Standard
-* What is AJAX? http://en.wikipedia.org/wiki/Ajax_(programming)
-\end_layout
-
-\begin_layout Standard
-AJAX (asynchronous JavaScript and XML) is a group of techniques that allow
- for interactive web applications.
- Using AJAX applications can talk to the server asynchronously and therefore
- not disrupt the display of the client.
- (this is awkward)
-\end_layout
-
-\begin_layout Standard
-* why is AJAX awesome? [example]
-\end_layout
-
-\begin_layout Standard
-Ajax allows for a much richer interface for a web application, and example
- is Google Suggest.
- When you start typing your search term, the word fragment is sent to the
- server and common completions of your term are sent back.
-\end_layout
-
-\begin_layout Standard
-* Method for async updates pulled from the client without a full page reload
-
-\end_layout
-
-\begin_layout Standard
-* Relies heavily on javascript and XML
-\end_layout
-
-\begin_layout Standard
-* Javascript client-side events (button push, timer, etc) trigger requests
- "behind the scenes"
-\end_layout
-
-\begin_layout Standard
-* Web 2.0 built on this
-\end_layout
-
-\begin_layout Standard
-* Using AJAX in Lift
-\end_layout
-
-\begin_layout Standard
-* Allows you to bind Javascript events (AJAX) to form elements, links, etc
-
-\end_layout
-
-\begin_layout Standard
-* Go through example HelloDarwin AJAX example
-\end_layout
-
-\begin_layout Standard
-* What is COMET? http://en.wikipedia.org/wiki/Comet_(programming)
-\end_layout
-
-\begin_layout Standard
-Comet is a method that uses long-polling to keep a connection between a
- browser and a server open, to allow the server to push data to the browser.
- An example of this would be a Stock Ticker.
- A user may have a page open that has a number of stock prices and as the
- price changes, the new value is pushed to the broswer without the need
- to refresh the page.
- Another example is the embedded Google Talk chat client in GMail.
- Instant messages from friends are automatically pushed to your browser.
-\end_layout
-\begin_layout Standard
-* Push to the browser
-\end_layout
-
-\begin_layout Standard
-* [Example] following a LiveBlog of a keynote presentation, elememts are
- pushed to your browser
-\end_layout
-
-\begin_layout Standard
-* Here's a super simple example - http://wiki.liftweb.net/index.php/CometActor
-
-\end_layout
-
-\begin_layout Standard
-* Method for async updates pushed
-\end_layout
-
-\begin_layout Standard
-*from server to client*
-\end_layout
-
-\begin_layout Standard
-* Connection is kept open
-\end_layout
-
-\begin_layout Standard
-* Streaming
-\end_layout
-
-\begin_layout Standard
-* Long polling
-\end_layout
-
-\begin_layout Standard
-* Scalability issues
-\end_layout
-
-\begin_layout Standard
-* Using COMET in Lift
-\end_layout
-
-\begin_layout Standard
-* CometActor
-\end_layout
-
-\begin_layout Standard
-* Mine Jorge's blog post: http://scala-blogs.org/2007/12/dynamic-web-applications
--with-lift-and.html
-\end_layout
-
-\begin_layout Standard
-* Go through Dynamic chat room example
\end_layout
\end_body
View
54 chapter18.lyx
@@ -0,0 +1,54 @@
+#LyX 1.5.3 created this file. For more info see http://www.lyx.org/
+\lyxformat 276
+\begin_document
+\begin_header
+\textclass book
+\language english
+\inputencoding auto
+\font_roman default
+\font_sans default
+\font_typewriter default
+\font_default_family default
+\font_sc false
+\font_osf false
+\font_sf_scale 100
+\font_tt_scale 100
+\graphics default
+\paperfontsize default
+\spacing single
+\papersize default
+\use_geometry false
+\use_amsmath 1
+\use_esint 1
+\cite_engine basic
+\use_bibtopic false
+\paperorientation portrait
+\secnumdepth 3
+\tocdepth 3
+\paragraph_separation indent
+\defskip medskip
+\quotes_language english
+\papercolumns 1
+\papersides 1
+\paperpagestyle default
+\tracking_changes false
+\output_changes false
+\author ""
+\end_header
+
+\begin_body
+
+\begin_layout Chapter
+Lift Widgets
+\end_layout
+
+\begin_layout Standard
+Let's build one together, Marius' Sparklines
+\end_layout
+
+\begin_layout Standard
+
+\end_layout
+
+\end_body
+\end_document
View
142 examples/helloworld/pom.xml
@@ -0,0 +1,142 @@
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>demo.helloworld</groupId>
+ <artifactId>helloworld</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>war</packaging>
+ <name>helloworld</name>
+ <inceptionYear>2007</inceptionYear>
+ <properties>
+ <scala.version>2.7.1</scala.version>
+ </properties>
+
+ <repositories>
+ <repository>
+ <id>scala-tools.org</id>
+ <name>Scala-Tools Maven2 Repository</name>
+ <url>http://scala-tools.org/repo-releases</url>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>scala-tools.org</id>
+ <name>Scala-Tools Maven2 Repository</name>
+ <url>http://scala-tools.org/repo-releases</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-library</artifactId>
+ <version>${scala.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>net.liftweb</groupId>
+ <artifactId>lift-webkit</artifactId>
+ <version>0.9</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ <version>[6.1.6,)</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- for LiftConsole -->
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-compiler</artifactId>
+ <version>${scala.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <sourceDirectory>src/main/scala</sourceDirectory>
+ <testSourceDirectory>src/test/scala</testSourceDirectory>
+ <plugins>
+ <plugin>
+ <groupId>org.scala-tools</groupId>
+ <artifactId>maven-scala-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compile</goal>
+ <goal>testCompile</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <scalaVersion>${scala.version}</scalaVersion>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <configuration>
+ <contextPath>/</contextPath>
+ <scanIntervalSeconds>5</scanIntervalSeconds>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>net.sf.alchim</groupId>
+ <artifactId>yuicompressor-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compress</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <nosuffix>true</nosuffix>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <configuration>
+ <downloadSources>true</downloadSources>
+ <excludes>
+ <exclude>org.scala-lang:scala-library</exclude>
+ </excludes>
+ <classpathContainers>
+ <classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER</classpathContainer>
+ </classpathContainers>
+ <projectnatures>
+ <java.lang.String>ch.epfl.lamp.sdt.core.scalanature</java.lang.String>
+ <java.lang.String>org.eclipse.jdt.core.javanature</java.lang.String>
+ </projectnatures>
+ <buildcommands>
+ <java.lang.String>ch.epfl.lamp.sdt.core.scalabuilder</java.lang.String>
+ </buildcommands>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.scala-tools</groupId>
+ <artifactId>maven-scala-plugin</artifactId>
+ <configuration>
+ <scalaVersion>${scala.version}</scalaVersion>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+</project>
View
23 examples/helloworld/src/main/scala/bootstrap/liftweb/Boot.scala
@@ -0,0 +1,23 @@
+package bootstrap.liftweb
+
+import net.liftweb.util._
+import net.liftweb.http._
+import net.liftweb.sitemap._
+import net.liftweb.sitemap.Loc._
+import Helpers._
+
+/**
+ * A class that's instantiated early and run. It allows the application
+ * to modify lift's environment
+ */
+class Boot {
+ def boot {
+ // where to search snippet
+ LiftRules.addToPackages("demo.helloworld")
+
+ // Build SiteMap
+ val entries = Menu(Loc("Home", "/", "Home")) :: Nil
+ LiftRules.setSiteMap(SiteMap(entries:_*))
+ }
+}
+
View
0 examples/helloworld/src/main/scala/demo/helloworld/comet/.keep
No changes.
View
0 examples/helloworld/src/main/scala/demo/helloworld/model/.keep
No changes.
View
0 examples/helloworld/src/main/scala/demo/helloworld/snippet/.keep
No changes.
View
6 examples/helloworld/src/main/scala/demo/helloworld/snippet/HelloWorld.scala
@@ -0,0 +1,6 @@
+package demo.helloworld.snippet
+
+class HelloWorld {
+ def howdy = <span>Welcome to helloworld at {new java.util.Date}</span>
+}
+
View
0 examples/helloworld/src/main/scala/demo/helloworld/view/.keep
No changes.
View
21 examples/helloworld/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!DOCTYPE web-app
+PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+"http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
+
+<web-app>
+<filter>
+ <filter-name>LiftFilter</filter-name>
+ <display-name>Lift Filter</display-name>
+ <description>The Filter that intercepts lift calls</description>
+ <filter-class>net.liftweb.http.LiftFilter</filter-class>
+</filter>
+
+
+<filter-mapping>
+ <filter-name>LiftFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+</filter-mapping>
+
+</web-app>
View
5 examples/helloworld/src/main/webapp/index.html
@@ -0,0 +1,5 @@
+<lift:surround with="default" at="content">
+ <h2>Welcome to your project!</h2>
+ <p><lift:helloWorld.howdy /></p>
+</lift:surround>
+
View
15 examples/helloworld/src/main/webapp/templates-hidden/default.html
@@ -0,0 +1,15 @@
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:lift="http://liftweb.net/">
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+ <meta name="description" content="" />
+ <meta name="keywords" content="" />
+
+ <title>demo.helloworld:helloworld:1.0-SNAPSHOT</title>
+ <script id="jquery" src="/classpath/jquery.js" type="text/javascript"></script>
+ </head>
+ <body>
+ <lift:bind name="content" />
+ <lift:Menu.builder />
+ <lift:msgs/>
+ </body>
+</html>
View
15 examples/helloworld/src/test/scala/LiftConsole.scala
@@ -0,0 +1,15 @@
+import bootstrap.liftweb.Boot
+import scala.tools.nsc.MainGenericRunner
+
+object LiftConsole {
+ def main(args : Array[String]) {
+ // Instantiate your project's Boot file
+ val b = new Boot();
+ // Boot your project
+ b.boot;
+ // Now run the MainGenericRunner to get your repl
+ MainGenericRunner.main(args)
+ // After the repl exits, then exit the scala script
+ exit(0)
+ }