Lift 2.0

Web Framework
Powered by Scala
          (Johansson)
Hybrid programming => OOP + FP


    foldLeft, map, reduce, etc ...

         patte...
Lift Architecture
Lift offers simple API to configure web
               application
                    SiteMap

                  UrlRewri...
SiteMap


val entries =
    Menu(Loc("404", List("404"), "404")) ::
    Menu(Loc("search", List("search"), "search")) ::
 ...
UrlRewriting

LiftRules.statelessRewrite.append {
     case RewriteRequest(
           ParsePath(
              "home" :: ...
Localization

LiftRules.localeCalculator =
        (req: Box[HTTPRequest]) => {
          Localization.is openOr
         ...
Variables - Session scope

    object Localization extends
  SessionVar[Box[Locale]](Empty)


          Localization.is


...
Variables - request scope

      The magic with S object

             S.param

               S.attr

               S.se...
MVC
 Model

Template

Snippet

 View
Model

Mapper - ORM Mapping

class NewsletterReceiver extends
    LongKeyedMapper[NewsletterReceiver] with IdPK {
   ...
}...
Template
                          default.html:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>...</head>
<body>
  <l...
Template - continued...
                       default.html:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>...</head>...
Snippet
Somewhere in template:

                         <lift:Articles>
                             <s:table/>
         ...
View
class ExpenseView extends LiftView {
   var expenseItems = ...

    override def dispatch = {
      case "enumerate" ...
Forms
<lift:Search.generateForm form="POST">
   <f:search/>
   <f:submit/>
</lift:Search.generateForm>


class Search exte...
JavaScript + jQuery and the band

                  JsExp

                 JsCmd

                JsCmds._

             ...
Comet applications

                                    Comet - according to wiki:
Comet is a neologism to describe a web ...
Upcoming SlideShare
Loading in …5
×

Lift 2 0

7,893 views
7,850 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
7,893
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Lift 2 0

  1. 1. Lift 2.0 Web Framework
  2. 2. Powered by Scala (Johansson) Hybrid programming => OOP + FP foldLeft, map, reduce, etc ... pattern matching class, object, trait concurency Is Scala better than Java?
  3. 3. Lift Architecture
  4. 4. Lift offers simple API to configure web application SiteMap UrlRewriting Database connection Requests specific handling Localization changing Customizing 404 - Page Not Found web.xml ...
  5. 5. SiteMap val entries = Menu(Loc("404", List("404"), "404")) :: Menu(Loc("search", List("search"), "search")) :: Nil LiftRules.setSiteMap(SiteMap(entries: _*))
  6. 6. UrlRewriting LiftRules.statelessRewrite.append { case RewriteRequest( ParsePath( "home" :: articleId :: Nil, _, _, _), _, _) => RewriteResponse( List("products"), Map("articleId" -> articleId)) }
  7. 7. Localization LiftRules.localeCalculator = (req: Box[HTTPRequest]) => { Localization.is openOr req match { case Full(e: HTTPRequest) => (e.locale) openOr Locale.getDefault case _ => Locale.getDefault } }
  8. 8. Variables - Session scope object Localization extends SessionVar[Box[Locale]](Empty) Localization.is Localization.set
  9. 9. Variables - request scope The magic with S object S.param S.attr S.set S object request/response settings
  10. 10. MVC Model Template Snippet View
  11. 11. Model Mapper - ORM Mapping class NewsletterReceiver extends LongKeyedMapper[NewsletterReceiver] with IdPK { ... } Boot class: DB.defineConnectionManager(...) object DBVendor extends ConnectionManager { ... }
  12. 12. Template default.html: <html xmlns="http://www.w3.org/1999/xhtml"> <head>...</head> <body> <lift:bind name="content"> </lift:bind> ... </body> index.html: <lift:surround with="default" at="content"> <lift:Hello.world /> </lift:surround>
  13. 13. Template - continued... default.html: <html xmlns="http://www.w3.org/1999/xhtml"> <head>...</head> <body> <lift:embed what="welcome" /> ... </body> welcome.html: <div id="WelcomeDiv"> <p>Herzlich Wilkommen!!!</p> </div>
  14. 14. Snippet Somewhere in template: <lift:Articles> <s:table/> </lift:Articles> What's behind the scene? class Articles extends StatefulSnippet { def render(in : NodeSeq) : NodeSeq = { val table = ... bind("s", in, "table" -> table) } }
  15. 15. View class ExpenseView extends LiftView { var expenseItems = ... override def dispatch = { case "enumerate" => doEnumerate _ } def doEnumerate () : NodeSeq = { ... <lift:surround with="default" at="content"> { expenseItems.toTable } </lift:surround> } }
  16. 16. Forms <lift:Search.generateForm form="POST"> <f:search/> <f:submit/> </lift:Search.generateForm> class Search extends StatefulSnippet { var searchText def generateForm(in : NodeSeq) : NodeSeq = bind("f", in, "search" -> SHtml.text(searchText, searchText = _) "submit" -> SHtml.submit("Search", processSearch)) }
  17. 17. JavaScript + jQuery and the band JsExp JsCmd JsCmds._ JsRaw artifact defining in Boot
  18. 18. Comet applications Comet - according to wiki: Comet is a neologism to describe a web application model in which a long-held HTTP request allows a web server to push data to a browser, without the browser explicitly requesting it. Scala Actors Ajax in Lift SHtml.ajaxCall SHtml.ajaxForm ajaxText, ajaxSubmit and many more...

×