Lift Mit Scala Ein BeföRderungsmittel In Die NäChste Etage Der Web Frameworks

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    2 Favorites

    Lift Mit Scala Ein BeföRderungsmittel In Die NäChste Etage Der Web Frameworks - Presentation Transcript

    1. Lift Webprogrammierung mit Scala Guy Philipp Bollbach, Christian Dietrich itemis
    2. Überblick  Einführung
    3. Überblick  Einführung  HelloWorld
    4. Überblick  Einführung  HelloWorld  Oberfläche
    5. Überblick  Einführung  HelloWorld  Oberfläche  Persistenz
    6. Überblick  Einführung  HelloWorld  Oberfläche  Persistenz  Allgemeines
    7. Überblick  Einführung  HelloWorld  Oberfläche  Persistenz  Allgemeines  Fazit
    8. Warum ausgerechnet wir?  itemis  Study Group  Scala  Lift
    9. Geschichte  Scala with Sails  Im Dezember 2006 (Version 0.0.1)  Von David Pollak
    10. Geschichte  Scala with Sails  Im Dezember 2006 (Version 0.0.1)  Von David Pollak  Lift  Seit Februar 2007 (Version 0.1.0)  Aktuell (Version 0.9.0)
    11. Die Idee  Ausdrucksstarkes und elegantes Web-Framework
    12. Die Idee  Ausdrucksstarkes und elegantes Web-Framework  Scala als Programmiersprache
    13. Die Idee  Ausdrucksstarkes und elegantes Web-Framework  Scala als Programmiersprache  Einfache und schnelle Entwicklung
    14. Die Idee  Ausdrucksstarkes und elegantes Web-Framework  Scala als Programmiersprache  Einfache und schnelle Entwicklung  Bedient sich bei den besten Features anderer Web-Frameworks
    15. Die „Paten“  Seaside (Smalltalk)
    16. Die „Paten“  Seaside (Smalltalk)  Django (Python)
    17. Die „Paten“  Seaside (Smalltalk)  Django (Python)  Wicket (Java)
    18. Die „Paten“  Seaside (Smalltalk)  Django (Python)  Wicket (Java)  Turbogears (Python)
    19. Die „Paten“  Seaside (Smalltalk)  Django (Python)  Wicket (Java)  Turbogears (Python)  Rails (Ruby)
    20. Das Lift-Framework im Überblick  in Scala geschrieben
    21. Das Lift-Framework im Überblick  in Scala geschrieben  auf der JVM lauffähig
    22. Das Lift-Framework im Überblick  in Scala geschrieben  auf der JVM lauffähig  Deployment in Servlet-Container
    23. Scala  universell einsetzbar
    24. Scala  universell einsetzbar  Eleganz durch Prägnanz
    25. Scala  universell einsetzbar  Eleganz durch Prägnanz  statisch getypt
    26. Scala  universell einsetzbar  Eleganz durch Prägnanz  statisch getypt  objektorientiert und funktional
    27. Scala  universell einsetzbar  Eleganz durch Prägnanz  statisch getypt  objektorientiert und funktional  mit Java interoperabel
    28. Scala on Fast Forward >>  kompakter und ausdruckstärker
    29. Scala on Fast Forward >>  kompakter und ausdruckstärker Java: List<Auto> tmp = new ArrayList<Auto>(); for (Reifen tmpReifen : reifenList) { tmp.add(new Auto(tmpReifen)); }
    30. Scala on Fast Forward >>  kompakter und ausdruckstärker Java: List<Auto> tmp = new ArrayList<Auto>(); for (Reifen tmpReifen : reifenList) { tmp.add(new Auto(tmpReifen)); } Scala: val tmp = reifenList.map{i => new Auto(i)}
    31. Scala on Fast Forward >>  stückweise Umdenken
    32. Scala on Fast Forward >>  stückweise Umdenken  verständlich für Java-isten
    33. Scala on Fast Forward >>  XML als integraler Bestandteil def addressNode(city : String, state : String, country : String) = { <address> <city>{city}</city> {if (state != null) <state>{state}</state> } <country>{country}</country> </address> }
    34. Scala on Fast Forward >>  Mixins/ Traits
    35. Scala on Fast Forward >>  Mixins/ Traits trait Similarity { def isSimilar(x: Any): Boolean def isNotSimilar(x: Any): Boolean = !isSimilar(x) }
    36. Scala on Fast Forward >>  Mixins/ Traits trait Similarity { def isSimilar(x: Any): Boolean def isNotSimilar(x: Any): Boolean = !isSimilar(x) } class Point(xc: Int, yc: Int) extends Similarity { var x: Int = xc var y: Int = yc def isSimilar(obj: Any) = obj.isInstanceOf[Point] && obj.asInstanceOf[Point].x == x }
    37. Hello World  im Schnelldurchlauf
    38. Hello World  Projekt anlegen mvn archetype:create -U -DarchetypeGroupId=net.liftweb -DarchetypeArtifactId=lift-archetype-basic -DarchetypeVersion=0.9 -DremoteRepositories= http://scala-tools.org/repo-releases -DgroupId=de.wjax.helloworld -DartifactId=hello-world-wjax
    39. Hello World II  Maven erzeugt Projektstruktur
    40. Hello World III cd hello-world-wjax mvn package mvn jetty:run
    41. Hello World III cd hello-world-wjax mvn package mvn jetty:run
    42. Hello World IV  Eigener Inhalt: „hello wjax“
    43. Hello World IV  Eigener Inhalt: „hello wjax“  HTML Seite anlegen
    44. Hello World IV  Eigener Inhalt: „hello wjax“  HTML Seite anlegen  Unter /src/main/webapp
    45. Hello World IV  Eigener Inhalt: „hello wjax“  HTML Seite anlegen  Unter /src/main/webapp  Template einbinden <lift:surround with=\"default\" at=\"content\"> </lift:surround>
    46. Hello World IV  Eigener Inhalt: „hello wjax“  HTML Seite anlegen  Unter /src/main/webapp  Template einbinden  Snippet aufrufen <lift:surround with=\"default\" at=\"content\"> <lift:snippet type=\"HelloWJAX:show\"/> </lift:surround>
    47. Hello World V  Snippet Klasse  Im snippet Verzeichnis ablegen <lift:surround with=\"default\" at=\"content\"> <lift:snippet type=\"HelloWJAX:show\" </lift:surround>
    48. Hello World V  Snippet Klasse  Im snippet Verzeichnis ablegen class HelloWJAX { def show = <span>Hello W-JAX!</span> } <lift:surround with=\"default\" at=\"content\"> <lift:snippet type=\"HelloWJAX:show\" </lift:surround>
    49. Hello World VI  Seite registrieren  Klasse: bootstrap/liftweb/Boot.scala
    50. Hello World VI  Seite registrieren  Klasse: bootstrap/liftweb/Boot.scala package bootstrap.liftweb class Boot { def boot { val entries = Menu(Loc(\"Home\",\"/\",\"Home\")) :: Menu(Loc(\"HelloWJAX\",\"/helloWJAX\",\"Hello W-JAX\")) :: User.sitemap } }
    51. Hello World VII  mvn compile
    52. Hello World VII  mvn compile
    53. View Konzept • plain XHTML
    54. View Konzept • plain XHTML • Preview im Browser
    55. View Konzept • plain XHTML • Preview im Browser • keine Business-Logik im XHTML
    56. View Konzept • plain XHTML • Preview im Browser • keine Business-Logik im XHTML • Snippets
    57. Snippet  lift-namespace Hello <lift:HelloForm.who /> <br/> <form> <label for=\"whoField\">Who :</label> <input type=\"text\" name=\"whoField\"/> <input type=\"submit\" value=\"send\"/> </form>
    58. Snippet • Ersetzung durch Rückgabewert import net.liftweb.http.S class HelloForm { def who = <b>{S.param(\"whoField\").openOr(\"\")}</b> }
    59. Snippet  Binding (XHTML)
    60. Snippet  Binding (XHTML) <lift:HelloForm2.show form=\"POST\"> Hello <hello:who/> <br/> <label for=\"whoField\">Who :</label> <hello:whoField/> <hello:submit/> </lift:HelloForm2.show>
    61. Snippet  Binding (Code) object who ... def show(xhtml: NodeSeq): NodeSeq = { bind(\"hello\", xhtml, \"whoField\" --> text(who.openOr(\"\"), v => who(Full(v))) % (\"size\" -> \"10\") % (\"id\" -> \"whoField\"), \"submit\" --> submit(\"Send\", ignore => { println(\"value:\" + who.openOr(\"\") }), \"who\" --> who.openOr(\"\") ) }
    62. Templates <body> <lift:bind name=\"content\" /> </body>
    63. Templates <body> <lift:bind name=\"content\" /> </body> <lift:surround with=\"default\" at=\"content\">
    64. Scopes • net.liftweb.http.S
    65. Scopes • net.liftweb.http.S • StatefulSnippet
    66. Scopes • net.liftweb.http.S • StatefulSnippet • RequestVar
    67. Scopes • net.liftweb.http.S • StatefulSnippet • RequestVar • SessionVar
    68. Scopes • net.liftweb.http.S • StatefulSnippet • RequestVar • SessionVar • Scala Object (=Singleton)
    69. SiteMap  Automatischer Menüeintrag
    70. SiteMap  Automatischer Menüeintrag  Sichtbarkeit konfigurierbar
    71. SiteMap  Automatischer Menüeintrag  Sichtbarkeit konfigurierbar  Menu(Loc(\"Unsichtbar\", \"/unsichtbar\", \"Unsichtbares Menu\",Hidden))  => Taucht nicht im Menü auf
    72. SiteMap  Automatischer Menüeintrag  Sichtbarkeit konfigurierbar  Menu(Loc(\"Unsichtbar\", \"/unsichtbar\", \"Unsichtbares Menu\",Hidden))  => Taucht nicht im Menü auf  Menu(Loc(\"Admin\", \"/admin\", \"Admin\", If(() => {user == admin}, NotFoundResponse))) => Nur für Admin sichtbar
    73. AJAX  Eingebauter AJAX Support class HelloAjax { def sample = { var count = 0; <span> { a(() => {count = count + 1; SetHtml(\"cnt_id\", Text(count.toString))}, <span>Click me! Count: <span id='cnt_id'>0</span> </span>) } </span> } }
    74. Comet  Problem: Server-To-Client Kommunikation
    75. Comet  Problem: Server-To-Client Kommunikation  Browser lädt die Seite neu  Langsam, Resourcenaufwändig
    76. Comet  Problem: Server-To-Client Kommunikation  Browser lädt die Seite neu  Langsam, Resourcenaufwändig  AJAX: Der Browser pollt  Resourcenaufwändig
    77. Comet  Problem: Server-To-Client Kommunikation  Browser lädt die Seite neu  Langsam, Resourcenhungrig  AJAX: Der Browser pollt  Resourcenhungrig  Comet-Style: Die Verbindung bleibt offen  Der Server streamt
    78. Comet II  Lift hat eingebauten Comet-Support Lift Server (Jetty) Browser CometActor Server CometActor Browser
    79. Comet III  Frontend <lift:surround with=\"default\" at=\"content\"> <lift:comet type=\"ChatClient\" /> </lift:surround>
    80. Comet III  Frontend <lift:surround with=\"default\" at=\"content\"> <lift:comet type=\"ChatClient\" /> </lift:surround>  Backend class ChatClient(info: CometActorInitInfo) extends CometActor(info) { override def localSetup {...} override def localShutdown {...} override def lowPriority = { } def render = ... }
    81. Persistence  eigener OR Mapper
    82. Persistence  eigener OR Mapper  Blog Beispiel
    83. Persistence II  KeyedMapper / KeyedMetaMapper class BlogEntry extends KeyedMapper[Long, BlogEntry]{ def getSingleton = BlogEntry def primaryKeyField = id object id extends MappedLongIndex(this) object title extends MappedString(this, 250) object content extends MappedTextarea(this,4000) }
    84. Persistence II  KeyedMapper / KeyedMetaMapper class BlogEntry extends KeyedMapper[Long, BlogEntry]{ def getSingleton = BlogEntry def primaryKeyField = id object id extends MappedLongIndex(this) object title extends MappedString(this, 250) object content extends MappedTextarea(this,4000) } object BlogEntry extends BlogEntry with KeyedMetaMapper[Long, BlogEntry] { override def dbTableName = \"blog_entry\" override def fieldOrder = id :: title :: content :: Nil }
    85. Persistence III  MappedFields (MappedBinary, MappedString, MappedBoolean, MappedDateTime, MappedDouble, MappedEMail, MappedLong, MappedPassword, MappedTextArea, ...)
    86. Persistence III  MappedFields (MappedBinary, MappedString, MappedBoolean, MappedDateTime, MappedDouble, MappedEMail, MappedLong, MappedPassword, MappedTextArea, ...)  Überschreiben möglich object content extends MappedTextarea(this,4000) { override def textareaRows = 10 override def textareaCols = 50 }
    87. Persistence III  MappedFields (MappedBinary, MappedString, MappedBoolean, MappedDateTime, MappedDouble, MappedEMail, MappedLong, MappedPassword, MappedTextArea, ...)  Überschreiben möglich object content extends MappedTextarea(this,4000) { override def textareaRows = 10 override def textareaCols = 50 }  Eigene MappedFields
    88. Persistence V  Anlegen, Speichern, Löschen  var e = new BlogEntry() ….  e.title(„W-JAX“)  e.save  e.delete_!
    89. Persistence V  Anlegen, Speichern, Löschen  var e = new BlogEntry() ….  e.title(„W-JAX“)  e.save  e.delete_!  Finden  BlogEntry.findAll()  BlogEntry.find(By(BlogEntry.title,“w-jax“))
    90. Persistence VI  Weiter Hilfsmethoden  toForm  htmlHeader  htmlLine  validate
    91. Persistence VIII  Schemifier  Erzeugt DB class Boot { def boot { Schemifier.schemify(true,Log.infoF _, User) } }
    92. Persistence VIII  Schemifier  Erzeugt DB class Boot { def boot { Schemifier.schemify(true,Log.infoF _, User, BlogEntry) } }  DataSource über JNDI class Boot { def boot { DefaultConnectionIdentifier.jndiName = \"jdbc/MyDataSource\" } }
    93. URL-Rewriting  ../freund/zeige?freund=2
    94. Pretty URLs  ../freund/zeige?freund=2  ../freund/zeige/2  ../friend/show/2
    95. Pretty URLs  ../freund/zeige?freund=2  ../freund/zeige/2  ../friend/show/2 LiftRules.addRewriteBefore { case RewriteRequest( ParsePath( \"friend\" :: \"show\" :: friendId :: Nil, _,_), _, _) => RewriteResponse( \"freund\" ::\"zeige\":: Nil, Map(\"freund\" -> friendId) ) }
    96. REST  RequestTypes  Pattern Matching  XML/JSON-Response
    97. XML-Response def showFriend(friendId: String): Can[XmlResponse] = Full(XmlResponse( <friends> { friendId match { case \"1\" => <friend name=\"Bill\"/> case \"2\" => <friend name=\"Bob\"/> case _ => \"no friend found\" } } </friends> ))
    98. JSON-Response def showFriendAsJson(friendId: String)(req: RequestState):Can[JsonResponse] = Full(JsonResponse( friendId match { case \"1\" => JsObj(\"firstname\" -> \"Wolfgang\", \"location\" -> JsObj( \"longitude\" -> \"49.02911\", \"latitude\" -> 8.241352\")) case _ => JsObj( \"error\" -> \"kein Geschlecht dieser Art gefunden\") }, Nil, Nil, 200 )) }
    99. Und wie entwickeln?  Maven  Projektanlage, Kompilieren, Deployen …
    100. Und wie entwickeln?  Maven  Projektanlage, Kompilieren, Deployen …  Eclipse / Netbeans  Einfache Scala Plugins  Syntaxhighlighting  Code Completion (rudimentär)  XHTML Editor  Kein Lift-Plugin
    101. Und wie entwickeln? II  Ressourcen  Source-Code  0.9.0: Google Code  0.10.0: GitHub
    102. Und wie entwickeln? II  Ressourcen  Source-Code  0.9.0: Google Code  0.10.0: GitHub  Wiki
    103. Und wie entwickeln? II  Ressourcen  Source-Code  0.9.0: Google Code  0.10.0: GitHub  Wiki  Google Group
    104. Und wie entwickeln? II  Ressourcen  Source-Code  0.9.0: Google Code  0.10.0: GitHub  Wiki  Google Group  Scala Docs
    105. Fazit - positiv  use case für Scala
    106. Fazit - positiv  use case für Scala  nah an HTTP
    107. Fazit - positiv  use case für Scala  nah an HTTP  elegant durch Scala
    108. Fazit - positiv  use case für Scala  nah an HTTP  elegant durch Scala  WOW Effekt
    109. Fazit - negativ  keine stabilen APIs
    110. Fazit - negativ  keine stabilen APIs  proprietär
    111. Fazit - negativ  keine stabilen APIs  proprietär  Hype um Scala
    112. Fazit - negativ  keine stabilen APIs  proprietär  Hype um Scala  One Man Show
    113. Fazit - negativ  keine stabilen APIs  proprietär  Hype um Scala  One Man Show  Einstiegshürde Scala
    114. Fazit - negativ  keine stabilen APIs  proprietär  Hype um Scala  One Man Show  Einstiegshürde Scala  Doku teilweise veraltet
    115. Fazit - negativ  keine stabilen APIs  proprietär  Hype um Scala  One Man Show  Einstiegshürde Scala  Doku teilweise veraltet  Scala Tooling
    116. Fazit - negativ  keine stabilen APIs  proprietär  Hype um Scala  One Man Show  Einstiegshürde Scala  Doku teilweise veraltet  Scala Tooling  keine Roadmap
    117. Was sagt der Erfinder?  „Need a team mentor to help with transition“
    118. Was sagt der Erfinder?  „Need a team mentor to help with transition“  „Amazing productivity for people once up functional programming curve“
    119. Was sagt der Erfinder?  „Need a team mentor to help with transition“  „Amazing productivity for people once up functional programming curve“  “There are two Lift books in the works”
    120. Was sagt der Erfinder?  „Need a team mentor to help with transition“  „Amazing productivity for people once up functional programming curve“  “There are two Lift books in the works”*  “plus a Lift seminar”
    121. Anwendbarkeit  Scala-Freunde: als Spielplatz
    122. Anwendbarkeit  Scala-Freunde: als Spielplatz  Nicht-Scala-Programmierer: Initialaufwand sehr hoch
    123. Demo  Lift-basierter Chat
    124. i18n  Properties Dateien  Im Classpath z.B. unter src/main/resources  lift_de_DE.properties, lift_en_US.properties, …  Paare key=value
    125. I18n  Properties Dateien  Im Classpath z.B. unter src/main/resources  lift_de_DE.properties, lift_en_US.properties, …  Paare key=value  In der XHTML Datei  <lift:loc locid=„key\">default value</lift:loc>
    126. I18n  Properties Dateien  Im Classpath z.B. unter src/main/resources  lift_de_DE.properties, lift_en_US.properties, …  Paare key=value  In der XHTML Datei  <lift:loc locid=„key\">default value</lift:loc>  Im Code  S.?(„key“)
    127. Errors, Warnings and Notices  Im Backend  S.error(„Fehler!“)  S.warning(„Achtung!“)  S.notice(„Info“)
    128. Errors, Warnings and Notices  Im Backend  S.error(„Fehler!“)  S.warning(„Achtung!“)  S.notice(„Info“)  Im Frontend <lift:snippet type=\"msgs\"> <lift:error_msg> Error! The details are: </lift:error_msg> <lift:error_class>errorBox</lift:error_class> ... </lift:snippet>

    + Michael JendryschikMichael Jendryschik, 8 months ago

    custom

    603 views, 2 favs, 2 embeds more stats

    More Info

    © All Rights Reserved

    Go to text version
    • Total Views 603
      • 534 on SlideShare
      • 69 from embeds
    • Comments 0
    • Favorites 2
    • Downloads 0
    Most viewed embeds
    • 61 views on http://www.itemis.de
    • 8 views on https://onion.net

    more

    All embeds
    • 61 views on http://www.itemis.de
    • 8 views on https://onion.net

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as innappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel

    Categories