+ All Categories
Home > Technology > Jax2009 inovex-tjoch-lift-20090423

Jax2009 inovex-tjoch-lift-20090423

Date post: 15-May-2015
Category:
Upload: inovex-gmbh
View: 297 times
Download: 0 times
Share this document with a friend
127
GeLiftete Web-Applikation mit Scala JAX 2009 Tobias Joch inovex GmbH Wir nutzen Technologien, um unsere Kunden glücklich zu machen. Und uns selbst.
Transcript
Page 1: Jax2009 inovex-tjoch-lift-20090423

GeLiftete Web-Applikation mit Scala

JAX 2009

Tobias Jochinovex GmbH

Wir nutzen Technologien, um unsere Kunden glücklich zu machen. Und uns selbst.

Page 2: Jax2009 inovex-tjoch-lift-20090423

2

ScalaLift

GrundlagenArchitektur ÜberblickModuleTemplate VerarbeitungTags und SnippetsHead MergeScopesI18nPersistenzAJAX

in ActionFazit / Ausblick / weiterführende Informationen

Page 3: Jax2009 inovex-tjoch-lift-20090423

3

Page 4: Jax2009 inovex-tjoch-lift-20090423

4

Scala = SCAlable LAnguage

Page 5: Jax2009 inovex-tjoch-lift-20090423

4

wächst mit den Bedürfnissen der Userkleine Skripte bis hin zu großen und komplexen SystemenMultiparadigmensprache

verbindet objektorientierte (imperative) und funktionale Programmierung

pragmatisch, typsicher, strikt objektorientiertinteroperabel mit Standard Plattformen (Java, .NET)

Scala = SCAlable LAnguage

Page 6: Jax2009 inovex-tjoch-lift-20090423

5

Wurzeln reichen zurück in das Jahr 1995Philip Wadler und Martin Odersky

Funktionale Programmiersprachen für die JVMPizzaGJ (Generic Language Extension für Java)javacJava Generics

1999 verfolgte Martin Odersky das Ziel funktionale mit OO Programmierung zu kombinieren

FunnelScala

*2001, 2003 erstes Public Release, 2006 Version 2.0, aktuell 2.7.4 RC1

Page 7: Jax2009 inovex-tjoch-lift-20090423

Ziel von Scala:Das Beste aus beiden Welten (OO und FP)

Statisch typisiert + TypinferenzFunktionen höherer OrdnungTraits, Mixin-KompositionOption-Klasse (None und Some vs. null)Pattern MatchingAlgebraische TypenNative XML-Unterstützung inkl. XPath Unterstützung (Bibliothek)Actor ModelCurryingAnonyme FunktionenParametrische Polymorphie 6

Page 8: Jax2009 inovex-tjoch-lift-20090423

Einige reservierte Schlüsselwörter in Scalaclass, case class, objectnew withextends abstract sealedtraitdef, var, valoverridematch, case

7

Page 9: Jax2009 inovex-tjoch-lift-20090423

8

in Action ;)

Page 10: Jax2009 inovex-tjoch-lift-20090423

Scala ShellInteractive Ruby Shell (IRB) ./scalaOptimal für schnelle Tests

9

Page 11: Jax2009 inovex-tjoch-lift-20090423

Scala ShellInteractive Ruby Shell (IRB) ./scalaOptimal für schnelle Tests

9

Page 12: Jax2009 inovex-tjoch-lift-20090423

Scala ShellInteractive Ruby Shell (IRB) ./scalaOptimal für schnelle Tests

9

Page 13: Jax2009 inovex-tjoch-lift-20090423

10

Imperative vs. funktionale Programmierung (I)

public class Example1 { public static void main(String[] args) { for (String arg : args) { System.out.println(arg); } }}

Page 14: Jax2009 inovex-tjoch-lift-20090423

10

Imperative vs. funktionale Programmierung (I)

object Example1 {def main(args: Array[String]) {

args.foreach(println)}

}

public class Example1 { public static void main(String[] args) { for (String arg : args) { System.out.println(arg); } }}

Page 15: Jax2009 inovex-tjoch-lift-20090423

11

Imperative vs. funktionale Programmierung (II)public class Example2 { public static void main(String[] args) { for (String arg : args) { if (arg.startsWith("JAX09")) { System.out.println(arg); } } }}

Page 16: Jax2009 inovex-tjoch-lift-20090423

11

Imperative vs. funktionale Programmierung (II)

object Example2 { def main(args: Array[String]) { args.filter(_.startsWith("JAX09")).foreach(println) }}

public class Example2 { public static void main(String[] args) { for (String arg : args) { if (arg.startsWith("JAX09")) { System.out.println(arg); } } }}

Page 17: Jax2009 inovex-tjoch-lift-20090423

12

Imperative vs. funktionale Programmierung (III)public class Example3 { public static void main(String[] args) { boolean exists = false; for (String arg : args) { if (arg.startsWith("JAX09")) { exists = true; break; } } System.out.print(exists); }}

Page 18: Jax2009 inovex-tjoch-lift-20090423

12

Imperative vs. funktionale Programmierung (III)

object Example3 { def main(args: Array[String]) { print(args.exists(_.startsWith("JAX09"))) }}

public class Example3 { public static void main(String[] args) { boolean exists = false; for (String arg : args) { if (arg.startsWith("JAX09")) { exists = true; break; } } System.out.print(exists); }}

Page 19: Jax2009 inovex-tjoch-lift-20090423

13

Grundlagen

Page 20: Jax2009 inovex-tjoch-lift-20090423

David PollakGründer von LiftKommerzielle Softwareentwicklung seit 1977Web-Applikationen seit 1996

15. Februar 2007:Initial Import (GitHub) in der Version 0.1.0Gründung von Lift als OS Projekt in 200726. Februar 2009:Lift 1.0Aktuelles Lift-Team besteht aus 13 ComitterAktive Community

http://groups.google.com/group/liftweb 14

Page 21: Jax2009 inovex-tjoch-lift-20090423

„Best of all“Scala als zugrundeliegende Sprache

nativer XML-Support (XHTML nativ innerhalb von Snippets!)Scala Actors für mächtige Comet-Anwendungen

fein granulare Sessions und Security (Seaside)schnelles Projektsetup durch „convention over configuration“ + geringe Turnaround-Zeiten (Rails)Django's "more than just CRUD is included"Designer freundliche Templates (Wicket / Lift View First)Offen für die Nutzung von zahlreichen OSS-Bibliotheken (Java)Etablierte Deployment-Prozesse (JEE / Java) 15

Page 22: Jax2009 inovex-tjoch-lift-20090423

Weitere Eigenschaften / Ziele von LiftSicherheit

XSS, replay Attacken, Parameter tamperingWartbarkeitSkalierbarkeitPerformanceHohe ProduktivitätEinfachConvention over configurationDRY

16

Page 23: Jax2009 inovex-tjoch-lift-20090423

„View First“ Design-PrinzipTemplates enthalten keinen CodePures XHTMLKönnen mit Standard Design-Werkzeugen bearbeitet werdenFrontend ist ohne Scala-Kenntnisse von einem Designer realisierbar

17

<lift:surround with="default" at="content"> <h2>Welcome to your project!</h2> <p><lift:helloWorld.howdy /></p> </lift:surround>

Page 24: Jax2009 inovex-tjoch-lift-20090423

18

Architektur Überblick

Page 25: Jax2009 inovex-tjoch-lift-20090423

Lift-Framework

19

Page 26: Jax2009 inovex-tjoch-lift-20090423

Lift-Framework

19Scala Framework

Page 27: Jax2009 inovex-tjoch-lift-20090423

Lift-Framework

19Scala Framework

Lift-Framework

Page 28: Jax2009 inovex-tjoch-lift-20090423

Lift-Framework

19Scala Framework

Lift-Framework

Lift Core

Page 29: Jax2009 inovex-tjoch-lift-20090423

Lift-Framework

19Scala Framework

Lift-Framework

Lift Core

Lift Webkit

Com

et

SH

tml

S

LiftR

ule

s

LiftS

essio

n

JS

AP

I

SiteM

ap

Menu, M

sgs,

CS

S

HT

TP

Auth

LiftR

esponse

Page 30: Jax2009 inovex-tjoch-lift-20090423

Lift-Framework

19Scala Framework

Lift-Framework

Lift Core

Lift Webkit

Com

et

SH

tml

S

LiftR

ule

s

LiftS

essio

n

JS

AP

I

SiteM

ap

Menu, M

sgs,

CS

S

HT

TP

Auth

LiftR

esponse

Mapper Record

Page 31: Jax2009 inovex-tjoch-lift-20090423

Lift-Framework

19Scala Framework

Lift-Framework

Lift Core

Lift Webkit

Com

et

SH

tml

S

LiftR

ule

s

LiftS

essio

n

JS

AP

I

SiteM

ap

Menu, M

sgs,

CS

S

HT

TP

Auth

LiftR

esponse

Mapper Record Testkit

Page 32: Jax2009 inovex-tjoch-lift-20090423

Lift-Framework

19Scala Framework

Lift-Framework

Lift Core

Lift Webkit

Com

et

SH

tml

S

LiftR

ule

s

LiftS

essio

n

JS

AP

I

SiteM

ap

Menu, M

sgs,

CS

S

HT

TP

Auth

LiftR

esponse

Mapper Record Testkit

Lift Util

Page 33: Jax2009 inovex-tjoch-lift-20090423

Lift-Framework

19Scala Framework

Lift-Framework

Lift Core

Lift Webkit

Com

et

SH

tml

S

LiftR

ule

s

LiftS

essio

n

JS

AP

I

SiteM

ap

Menu, M

sgs,

CS

S

HT

TP

Auth

LiftR

esponse

Mapper Record Testkit

Lift Util

Lift XMPP

Lift Facebook

Lift Widgets

Lift OpenId

Lift OAuth

Lift Paypal

Lift AMQP

Page 34: Jax2009 inovex-tjoch-lift-20090423

Grobe Architektur einer Lift-Applikation

20

Page 35: Jax2009 inovex-tjoch-lift-20090423

Java Virtual Machine

Grobe Architektur einer Lift-Applikation

20

Page 36: Jax2009 inovex-tjoch-lift-20090423

Java Virtual Machine

Grobe Architektur einer Lift-Applikation

20

Servlet Container (e.g. Jetty or Tomcat)

Page 37: Jax2009 inovex-tjoch-lift-20090423

Java Virtual Machine

Grobe Architektur einer Lift-Applikation

20

Servlet Container (e.g. Jetty or Tomcat)

Lift Framework

Page 38: Jax2009 inovex-tjoch-lift-20090423

Java Virtual Machine

Grobe Architektur einer Lift-Applikation

20

Servlet Container (e.g. Jetty or Tomcat)

Templates

Lift Framework

Page 39: Jax2009 inovex-tjoch-lift-20090423

Java Virtual Machine

Grobe Architektur einer Lift-Applikation

20

Servlet Container (e.g. Jetty or Tomcat)

Templates

Snippets

Lift Framework

Page 40: Jax2009 inovex-tjoch-lift-20090423

Java Virtual Machine

Grobe Architektur einer Lift-Applikation

20

Servlet Container (e.g. Jetty or Tomcat)

Templates

Views

Snippets

Lift Framework

Page 41: Jax2009 inovex-tjoch-lift-20090423

Java Virtual Machine

Grobe Architektur einer Lift-Applikation

20

Servlet Container (e.g. Jetty or Tomcat)

Templates

Views

Snippets

Boot.scala (LiftRules etc,)

Lift Framework

Page 42: Jax2009 inovex-tjoch-lift-20090423

Java Virtual Machine

Grobe Architektur einer Lift-Applikation

20

Servlet Container (e.g. Jetty or Tomcat)

Templates

Views

Snippets

Boot.scala (LiftRules etc,)

Model

Lift Framework

Page 43: Jax2009 inovex-tjoch-lift-20090423

Java Virtual Machine

Grobe Architektur einer Lift-Applikation

20

Servlet Container (e.g. Jetty or Tomcat)

Templates

Views

Snippets

Boot.scala (LiftRules etc,)

LiftFilter Model

Lift Framework

Page 44: Jax2009 inovex-tjoch-lift-20090423

Java Virtual Machine

Grobe Architektur einer Lift-Applikation

20

Servlet Container (e.g. Jetty or Tomcat)

Templates

Views

Snippets

Boot.scala (LiftRules etc,)

LiftServlet

LiftFilter Model

Lift Framework

Page 45: Jax2009 inovex-tjoch-lift-20090423

Java Virtual Machine

Grobe Architektur einer Lift-Applikation

20

Servlet Container (e.g. Jetty or Tomcat)

Templates

Views

Snippets

Boot.scala (LiftRules etc,)

LiftServlet

LiftFilter Model

Lift Framework

DefaultServlet

Page 46: Jax2009 inovex-tjoch-lift-20090423

Grober Ablauf einer Anfragenbearbeitung

21

Request URL rewrite View Responsecustom dispatch

Response

Response

ResponseTemplate

Page 47: Jax2009 inovex-tjoch-lift-20090423

Grober Ablauf einer Anfragenbearbeitung

21

Request URL rewrite View Responsecustom dispatch

Response

Response

Response

Template

Page 48: Jax2009 inovex-tjoch-lift-20090423

Template VerarbeitungRequest Mapping nach folgendem Schema

22

Template

Page 49: Jax2009 inovex-tjoch-lift-20090423

Template VerarbeitungRequest Mapping nach folgendem Schema

22

<path>[_<language, optional>][.<suffix>]

Template

Page 50: Jax2009 inovex-tjoch-lift-20090423

Template VerarbeitungRequest Mapping nach folgendem Schema

22

<path>[_<language, optional>][.<suffix>]

Lift wählt die passende Sprache und Endung

Template

Page 51: Jax2009 inovex-tjoch-lift-20090423

Template VerarbeitungRequest Mapping nach folgendem Schema

22

<path>[_<language, optional>][.<suffix>]

Lift wählt die passende Sprache und EndungLinks ohne Sprache und Endung angeben

Template

Page 52: Jax2009 inovex-tjoch-lift-20090423

Template VerarbeitungRequest Mapping nach folgendem Schema

22

<path>[_<language, optional>][.<suffix>]

Lift wählt die passende Sprache und EndungLinks ohne Sprache und Endung angeben

Lift versteckt Templates und Ressourcen in Verzeichnissen welche als Endung -hidden im Namen tragen

Template

Page 53: Jax2009 inovex-tjoch-lift-20090423

Template VerarbeitungRequest Mapping nach folgendem Schema

22

<path>[_<language, optional>][.<suffix>]

Lift wählt die passende Sprache und EndungLinks ohne Sprache und Endung angeben

Lift versteckt Templates und Ressourcen in Verzeichnissen welche als Endung -hidden im Namen tragen

Template

Page 54: Jax2009 inovex-tjoch-lift-20090423

23

Template

Page 55: Jax2009 inovex-tjoch-lift-20090423

Templates = Content + Tags + Snippets

23

Template

Page 56: Jax2009 inovex-tjoch-lift-20090423

Templates = Content + Tags + SnippetsTags = Lift spezifische Funktionen

surroundbindembedcometloc

23

Template

Page 57: Jax2009 inovex-tjoch-lift-20090423

Templates = Content + Tags + SnippetsTags = Lift spezifische Funktionen

surroundbindembedcometloc

Snippetsvergleichbar mit Taglibs<lift:snippet type=Jax:render /> <lift:Jax.render /> <lift:Jax /> 23

Template

Page 58: Jax2009 inovex-tjoch-lift-20090423

24

Template Verarbeitung von Außen nach Innen

Template

Page 59: Jax2009 inovex-tjoch-lift-20090423

24

Template Verarbeitung von Außen nach Innen

<lift:surround with="default" at="content"> <h2>Welcome to your project!</h2> <p><lift:HelloWorld.howdy /></p> </lift:surround>

/index.html

Template

Page 60: Jax2009 inovex-tjoch-lift-20090423

24

Template Verarbeitung von Außen nach Innen

<lift:surround with="default" at="content"> <h2>Welcome to your project!</h2> <p><lift:HelloWorld.howdy /></p> </lift:surround>

/index.html

/templates-hidden/default.html

<html xmlns="..." xmlns:lift="http://liftweb.net/"> <head>...</head> <body>

...<lift:bind name="content" />

</body></html>

Template

Page 61: Jax2009 inovex-tjoch-lift-20090423

24

Template Verarbeitung von Außen nach Innen

<lift:surround with="default" at="content"> <h2>Welcome to your project!</h2> <p><lift:HelloWorld.howdy /></p> </lift:surround>

/index.html

/templates-hidden/default.html

<html xmlns="..." xmlns:lift="http://liftweb.net/"> <head>...</head> <body>

...<lift:bind name="content" />

</body></html>

Ausführung von HelloWorld#howdy

Template

Page 62: Jax2009 inovex-tjoch-lift-20090423

25

Head Merge

Template

Page 63: Jax2009 inovex-tjoch-lift-20090423

25

Head Merge

Template

<lift:surround with="default" at="content"> <head><script type="text/javascript">...</script>...</head> <h2>Welcome to your project!</h2> <p><lift:helloWorld.howdy /></p></lift:surround>

/index.html

Page 64: Jax2009 inovex-tjoch-lift-20090423

25

Head Merge

Template

<lift:surround with="default" at="content"> <head><script type="text/javascript">...</script>...</head> <h2>Welcome to your project!</h2> <p><lift:helloWorld.howdy /></p></lift:surround>

/index.html

/templates-hidden/default.html

<html xmlns="..." xmlns:lift="http://liftweb.net/"> <head>...</head> <body>

...<lift:bind name="content" />

</body></html>

Page 65: Jax2009 inovex-tjoch-lift-20090423

25

Head Merge

Template

<lift:surround with="default" at="content"> <head><script type="text/javascript">...</script>...</head> <h2>Welcome to your project!</h2> <p><lift:helloWorld.howdy /></p></lift:surround>

/index.html

/templates-hidden/default.html

<html xmlns="..." xmlns:lift="http://liftweb.net/"> <head>...</head> <body>

...<lift:bind name="content" />

</body></html>

Page 66: Jax2009 inovex-tjoch-lift-20090423

ScopesSStateful SnippetRequestVarSessionVarScala Object (Singleton)

26

Page 67: Jax2009 inovex-tjoch-lift-20090423

Internationalisierung / I18njava.util.Localejava.util.ResourceBundle

LiftRules.resourceNames

Ermittlung der aktuellen SpracheLiftRules.localeCalculator

Request-HeaderFallback: Locale.getDefault()

SnippetsS.?

Templates

27

<lift:loc locid="lift">Aufzug</lift:loc><lift:loc>lift</lift:loc>

Page 68: Jax2009 inovex-tjoch-lift-20090423

Persistenz in LiftMapperRecordJPAJDOHibernate...

Lift selbst ist Persistenz agnostisch

28

Page 69: Jax2009 inovex-tjoch-lift-20090423

AJAX in LiftSHtml

ajaxButtonajaxTextajaxCheckbox...

29

def render(in: NodeSeq): NodeSeq =SHtml.ajaxButton("Click me ;)", () => {

println("Yes, thanks!") JsCmds.SetHtml("click-div", Text("Yes, thanks!"))

})

Page 70: Jax2009 inovex-tjoch-lift-20090423

30

in Action ;)

Page 71: Jax2009 inovex-tjoch-lift-20090423

EntwicklungsumgebungJava (>= 5)Maven (>= 2.0.9)Web-Container (Jetty, Tomcat, ...)

Optional, aber nützlichJavaRebel (JVM Plugin / Java Agent)IDE mit Scala Support / Plugin (Eclipse, IDEA, Netbeans, ...)

http://www.scala-lang.org/scala-eclipse-plugin

31

Page 72: Jax2009 inovex-tjoch-lift-20090423

32

Projekt anlegen

Page 73: Jax2009 inovex-tjoch-lift-20090423

32

Projekt anlegen

$mvn archetype:generate -U -DarchetypeGroupId=net.liftweb -DarchetypeArtifactId=lift-archetype-basic -DarchetypeVersion=1.0 -DgroupId=de.inovex.jax2009.lift -DartifactId=lift-demo

Page 74: Jax2009 inovex-tjoch-lift-20090423

32

Projekt anlegen

$mvn archetype:generate -U -DarchetypeGroupId=net.liftweb -DarchetypeArtifactId=lift-archetype-basic -DarchetypeVersion=1.0 -DgroupId=de.inovex.jax2009.lift -DartifactId=lift-demo

$cd lift-demo && mvn eclipse:eclipse

Import in Eclipse vorbereiten

Page 75: Jax2009 inovex-tjoch-lift-20090423

33

Projektlayout

Page 76: Jax2009 inovex-tjoch-lift-20090423

33

Projektlayout

Page 77: Jax2009 inovex-tjoch-lift-20090423

33

Projektlayout

Page 78: Jax2009 inovex-tjoch-lift-20090423

34

Ausführen

Page 79: Jax2009 inovex-tjoch-lift-20090423

34

Ausführen

$mvn jetty:run

Page 80: Jax2009 inovex-tjoch-lift-20090423

34

Ausführen

$mvn jetty:run

Page 81: Jax2009 inovex-tjoch-lift-20090423

35

index.html

Page 82: Jax2009 inovex-tjoch-lift-20090423

<lift:surround with="default" at="content"> <h2>Welcome to your project!</h2> <p><lift:helloWorld.howdy /></p> </lift:surround>

35

index.html

Page 83: Jax2009 inovex-tjoch-lift-20090423

<lift:surround with="default" at="content"> <h2>Welcome to your project!</h2> <p><lift:helloWorld.howdy /></p> </lift:surround>

35

index.html

HelloWorld.scala

Page 84: Jax2009 inovex-tjoch-lift-20090423

import java.util.Date

class HelloWorld { def howdy = <span>Welcome to lift-demo at {new Date}</span> }

<lift:surround with="default" at="content"> <h2>Welcome to your project!</h2> <p><lift:helloWorld.howdy /></p> </lift:surround>

35

index.html

HelloWorld.scala

Page 85: Jax2009 inovex-tjoch-lift-20090423

import java.util.Date

class HelloWorld { def howdy = <span>Welcome to lift-demo at {new Date}</span> }

<lift:surround with="default" at="content"> <h2>Welcome to your project!</h2> <p><lift:helloWorld.howdy /></p> </lift:surround>

35

index.html

HelloWorld.scala

Page 86: Jax2009 inovex-tjoch-lift-20090423

import java.util.Date

class HelloWorld { def howdy = <span>Welcome to lift-demo at {new Date}</span> }

<lift:surround with="default" at="content"> <h2>Welcome to your project!</h2> <p><lift:helloWorld.howdy /></p> </lift:surround>

35

index.html

HelloWorld.scala

Page 87: Jax2009 inovex-tjoch-lift-20090423

import java.util.Date

class HelloWorld { def howdy = <span>Welcome to lift-demo at {new Date}</span> }

<lift:surround with="default" at="content"> <h2>Welcome to your project!</h2> <p><lift:helloWorld.howdy /></p> </lift:surround>

35

index.html

HelloWorld.scala

Page 88: Jax2009 inovex-tjoch-lift-20090423

import java.util.Date

class HelloWorld { def howdy = <span>Welcome to lift-demo at {new Date}</span> }

<lift:surround with="default" at="content"> <h2>Welcome to your project!</h2> <p><lift:helloWorld.howdy /></p> </lift:surround>

35

index.html

HelloWorld.scala

Page 89: Jax2009 inovex-tjoch-lift-20090423

import java.util.Date

class HelloWorld { def howdy = <span>Welcome to lift-demo at {new Date}</span> }

<lift:surround with="default" at="content"> <h2>Welcome to your project!</h2> <p><lift:helloWorld.howdy /></p> </lift:surround>

35

index.html

HelloWorld.scala

Page 90: Jax2009 inovex-tjoch-lift-20090423

import java.util.Date

class HelloWorld { def howdy = <span>Welcome to lift-demo at {new Date}</span> }

<lift:surround with="default" at="content"> <h2>Welcome to your project!</h2> <p><lift:helloWorld.howdy /></p> </lift:surround>

35

index.html

HelloWorld.scala

Page 91: Jax2009 inovex-tjoch-lift-20090423

36

default.html

Page 92: Jax2009 inovex-tjoch-lift-20090423

<div class="container"> <div class="column span-12 last" style="text-align: right"> <h1 class="alt">lift-demo <img id="ajax-loader" style="display:none; margin-bottom: 0px; margin-left: 5px" src="/images/ajax-loader.gif"/></h1> </div> <hr/> <div class="column span-6 colborder sidebar"> <hr class="space" /> <lift:Menu.builder /> <div> <lift:snippet type="msgs"/> <hr class="space" /> </div> </div> <div class="column span-17 last"> <lift:bind name="content" /> </div> <hr /> <div class="column span-23 last" style="text-align: center"> <h4 class="alt"> <a href="http://liftweb.net"><i>Lift</i></a> is Copyright 2007-2009 WorldWide Conferencing, LLC. Distributed under an Apache 2.0 License.</h4> </div> </div> 36

default.html

Page 93: Jax2009 inovex-tjoch-lift-20090423

<div class="container"> <div class="column span-12 last" style="text-align: right"> <h1 class="alt">lift-demo <img id="ajax-loader" style="display:none; margin-bottom: 0px; margin-left: 5px" src="/images/ajax-loader.gif"/></h1> </div> <hr/> <div class="column span-6 colborder sidebar"> <hr class="space" /> <lift:Menu.builder /> <div> <lift:snippet type="msgs"/> <hr class="space" /> </div> </div> <div class="column span-17 last"> <lift:bind name="content" /> </div> <hr /> <div class="column span-23 last" style="text-align: center"> <h4 class="alt"> <a href="http://liftweb.net"><i>Lift</i></a> is Copyright 2007-2009 WorldWide Conferencing, LLC. Distributed under an Apache 2.0 License.</h4> </div> </div> 36

default.html

Page 94: Jax2009 inovex-tjoch-lift-20090423

<div class="container"> <div class="column span-12 last" style="text-align: right"> <h1 class="alt">lift-demo <img id="ajax-loader" style="display:none; margin-bottom: 0px; margin-left: 5px" src="/images/ajax-loader.gif"/></h1> </div> <hr/> <div class="column span-6 colborder sidebar"> <hr class="space" /> <lift:Menu.builder /> <div> <lift:snippet type="msgs"/> <hr class="space" /> </div> </div> <div class="column span-17 last"> <lift:bind name="content" /> </div> <hr /> <div class="column span-23 last" style="text-align: center"> <h4 class="alt"> <a href="http://liftweb.net"><i>Lift</i></a> is Copyright 2007-2009 WorldWide Conferencing, LLC. Distributed under an Apache 2.0 License.</h4> </div> </div> 36

default.html

Page 95: Jax2009 inovex-tjoch-lift-20090423

<div class="container"> <div class="column span-12 last" style="text-align: right"> <h1 class="alt">lift-demo <img id="ajax-loader" style="display:none; margin-bottom: 0px; margin-left: 5px" src="/images/ajax-loader.gif"/></h1> </div> <hr/> <div class="column span-6 colborder sidebar"> <hr class="space" /> <lift:Menu.builder /> <div> <lift:snippet type="msgs"/> <hr class="space" /> </div> </div> <div class="column span-17 last"> <lift:bind name="content" /> </div> <hr /> <div class="column span-23 last" style="text-align: center"> <h4 class="alt"> <a href="http://liftweb.net"><i>Lift</i></a> is Copyright 2007-2009 WorldWide Conferencing, LLC. Distributed under an Apache 2.0 License.</h4> </div> </div> 36

default.html

Page 96: Jax2009 inovex-tjoch-lift-20090423

<div class="container"> <div class="column span-12 last" style="text-align: right"> <h1 class="alt">lift-demo <img id="ajax-loader" style="display:none; margin-bottom: 0px; margin-left: 5px" src="/images/ajax-loader.gif"/></h1> </div> <hr/> <div class="column span-6 colborder sidebar"> <hr class="space" /> <lift:Menu.builder /> <div> <lift:snippet type="msgs"/> <hr class="space" /> </div> </div> <div class="column span-17 last"> <lift:bind name="content" /> </div> <hr /> <div class="column span-23 last" style="text-align: center"> <h4 class="alt"> <a href="http://liftweb.net"><i>Lift</i></a> is Copyright 2007-2009 WorldWide Conferencing, LLC. Distributed under an Apache 2.0 License.</h4> </div> </div> 36

default.html

Page 97: Jax2009 inovex-tjoch-lift-20090423

<div class="container"> <div class="column span-12 last" style="text-align: right"> <h1 class="alt">lift-demo <img id="ajax-loader" style="display:none; margin-bottom: 0px; margin-left: 5px" src="/images/ajax-loader.gif"/></h1> </div> <hr/> <div class="column span-6 colborder sidebar"> <hr class="space" /> <lift:Menu.builder /> <div> <lift:snippet type="msgs"/> <hr class="space" /> </div> </div> <div class="column span-17 last"> <lift:bind name="content" /> </div> <hr /> <div class="column span-23 last" style="text-align: center"> <h4 class="alt"> <a href="http://liftweb.net"><i>Lift</i></a> is Copyright 2007-2009 WorldWide Conferencing, LLC. Distributed under an Apache 2.0 License.</h4> </div> </div> 36

default.html

Page 98: Jax2009 inovex-tjoch-lift-20090423

37

Boot.scala

Page 99: Jax2009 inovex-tjoch-lift-20090423

37

Boot.scala def boot { if (!DB.jndiJdbcConnAvailable_?) DB.defineConnectionManager(DefaultConnectionIdentifier, DBVendor)

// where to search snippet LiftRules.addToPackages("de.inovex.jax2009.lift") // create or update the database schema Schemifier.schemify(true, Log.infoF _, User)

// build site map val entries = Menu(Loc("Home", List("index"), "Home")) :: User.sitemap LiftRules.setSiteMap(SiteMap(entries:_*))

// Show the spinny image when an Ajax call starts LiftRules.ajaxStart = Full(() => LiftRules.jsArtifacts.show("ajax-loader").cmd)

// Make the spinny image go away when it ends LiftRules.ajaxEnd = Full(() => LiftRules.jsArtifacts.hide("ajax-loader").cmd)

// force the request to be UTF-8 LiftRules.early.append(makeUtf8)

S.addAround(DB.buildLoanWrapper) }

Page 100: Jax2009 inovex-tjoch-lift-20090423

38

Rekursive Template Komposition

Page 101: Jax2009 inovex-tjoch-lift-20090423

38

Rekursive Template Komposition

class HelloWorld { def howdy = <span>Welcome to lift-demo at {new Date} at <lift:helloWorld.howdy2 /></span> def howdy2 = <span>JAX 2009!</span> }

Page 102: Jax2009 inovex-tjoch-lift-20090423

38

Rekursive Template Komposition

class HelloWorld { def howdy = <span>Welcome to lift-demo at {new Date} at <lift:helloWorld.howdy2 /></span> def howdy2 = <span>JAX 2009!</span> }

Page 103: Jax2009 inovex-tjoch-lift-20090423

38

Rekursive Template Komposition

class HelloWorld { def howdy = <span>Welcome to lift-demo at {new Date} at <lift:helloWorld.howdy2 /></span> def howdy2 = <span>JAX 2009!</span> }

Page 104: Jax2009 inovex-tjoch-lift-20090423

38

Rekursive Template Komposition

class HelloWorld { def howdy = <span>Welcome to lift-demo at {new Date} at <lift:helloWorld.howdy2 /></span> def howdy2 = <span>JAX 2009!</span> }

Page 105: Jax2009 inovex-tjoch-lift-20090423

39

Formulare <lift:surround with="default" at="content">

<h2>Very first form example:</h2> <p> <lift:FormExample form="POST"> <f:name><input type="text"/></f:name> <input type="submit" value="Post"/> </lift:FormExample> </p> </lift:surround>

Page 106: Jax2009 inovex-tjoch-lift-20090423

39

Formulare <lift:surround with="default" at="content">

<h2>Very first form example:</h2> <p> <lift:FormExample form="POST"> <f:name><input type="text"/></f:name> <input type="submit" value="Post"/> </lift:FormExample> </p> </lift:surround>

class FormExample { def render(xhtml: NodeSeq) = { bind("f", xhtml, "name" -> text("", println(_))) } }

Page 107: Jax2009 inovex-tjoch-lift-20090423

39

Formulare <lift:surround with="default" at="content">

<h2>Very first form example:</h2> <p> <lift:FormExample form="POST"> <f:name><input type="text"/></f:name> <input type="submit" value="Post"/> </lift:FormExample> </p> </lift:surround>

class FormExample { def render(xhtml: NodeSeq) = { bind("f", xhtml, "name" -> text("", println(_))) } }

Page 108: Jax2009 inovex-tjoch-lift-20090423

39

Formulare <lift:surround with="default" at="content">

<h2>Very first form example:</h2> <p> <lift:FormExample form="POST"> <f:name><input type="text"/></f:name> <input type="submit" value="Post"/> </lift:FormExample> </p> </lift:surround>

class FormExample { def render(xhtml: NodeSeq) = { bind("f", xhtml, "name" -> text("", println(_))) } }

Page 109: Jax2009 inovex-tjoch-lift-20090423

39

Formulare <lift:surround with="default" at="content">

<h2>Very first form example:</h2> <p> <lift:FormExample form="POST"> <f:name><input type="text"/></f:name> <input type="submit" value="Post"/> </lift:FormExample> </p> </lift:surround>

class FormExample { def render(xhtml: NodeSeq) = { bind("f", xhtml, "name" -> text("", println(_))) } }

Page 110: Jax2009 inovex-tjoch-lift-20090423

39

Formulare <lift:surround with="default" at="content">

<h2>Very first form example:</h2> <p> <lift:FormExample form="POST"> <f:name><input type="text"/></f:name> <input type="submit" value="Post"/> </lift:FormExample> </p> </lift:surround>

class FormExample { def render(xhtml: NodeSeq) = { bind("f", xhtml, "name" -> text("", println(_))) } }

// in boot.scala: val entries = Menu(Loc("Home", List("index"), "Home")) :: Menu(Loc("form1", List("veryFirstForm"), "Example")) :: User.sitemap LiftRules.setSiteMap(SiteMap(entries:_*))

Page 111: Jax2009 inovex-tjoch-lift-20090423

39

Formulare <lift:surround with="default" at="content">

<h2>Very first form example:</h2> <p> <lift:FormExample form="POST"> <f:name><input type="text"/></f:name> <input type="submit" value="Post"/> </lift:FormExample> </p> </lift:surround>

class FormExample { def render(xhtml: NodeSeq) = { bind("f", xhtml, "name" -> text("", println(_))) } }

// in boot.scala: val entries = Menu(Loc("Home", List("index"), "Home")) :: Menu(Loc("form1", List("veryFirstForm"), "Example")) :: User.sitemap LiftRules.setSiteMap(SiteMap(entries:_*))

Page 112: Jax2009 inovex-tjoch-lift-20090423

40

Formulare

Page 113: Jax2009 inovex-tjoch-lift-20090423

40

Formulare

Page 114: Jax2009 inovex-tjoch-lift-20090423

40

JAX 2009! INFO - Service request (POST) /veryFirstForm took 61 Milliseconds

Formulare

Page 115: Jax2009 inovex-tjoch-lift-20090423

40

JAX 2009! INFO - Service request (POST) /veryFirstForm took 61 Milliseconds

Formulare

Page 116: Jax2009 inovex-tjoch-lift-20090423

41

more in Action ;)

Page 117: Jax2009 inovex-tjoch-lift-20090423

Beispiel-Applikation(en)Scala Actors / CometModelle / OR-MappingSiteMapMessages...

42

Page 118: Jax2009 inovex-tjoch-lift-20090423

Beispiel-Applikation(en)Scala Actors / CometModelle / OR-MappingSiteMapMessages...

42

Demo !

Page 119: Jax2009 inovex-tjoch-lift-20090423

43

Zusammenfassung

Page 120: Jax2009 inovex-tjoch-lift-20090423

44

Page 121: Jax2009 inovex-tjoch-lift-20090423

ProSehr schicke Sprachfeatures„Best of all“ PrinzipJunge und dynamische CommunitySehr gut für interaktive Webbapplikationen („Real time web“)Native, volle JVM Geschwindigkeit100% kompatibel mit JavaLäuft auf Standard Servlet-Container (Jetty, Tomcat, ...)

44

Page 122: Jax2009 inovex-tjoch-lift-20090423

ProSehr schicke Sprachfeatures„Best of all“ PrinzipJunge und dynamische CommunitySehr gut für interaktive Webbapplikationen („Real time web“)Native, volle JVM Geschwindigkeit100% kompatibel mit JavaLäuft auf Standard Servlet-Container (Jetty, Tomcat, ...)

ConsSteile LernkurveWenig Scala Ressourcen am Markt verfügbar (XING: 164)Noch weniger Lift Ressourcen verfügbar (XING: 3)Keine mir bekannten große Installationen aktuell vorzeigbar 44

Page 123: Jax2009 inovex-tjoch-lift-20090423

Aktuell Roadmap 1.1 (Auszug der Lift Newsgroup)Improved documentation: better VScalaDoc coverage as well as better tutorial and cook-book documentation.Improved J2EE support including JTA and Portlets.Finish Record/Field code with backing store including JDBC, JPA and Goat Rodeo (what's Goat Rodeo? http://goatrodeo.org)Improved client-side JavaScript support and better JavaScript abstractions.Client/Server data synchronization (integrated with Record/Field)Improved support for REST.Improved performance including caching templates when running in production mode.OSGi support.Improved testing framework and better testing support when running in "test" mode.Implement Servlet 3.0 support.HTML 5 and Web Sockets support and integration with Kaazing's Web Sockets server. Also, sensing which browser is making the request and performing optimizations based on that browser's characteristics (specifically, Chrome and Firefox 3.1 support) 45

Page 124: Jax2009 inovex-tjoch-lift-20090423

Ressourcen im NetzScala

http://scala-lang.orgLift

http://liftweb.net/http://liftweb.net/docs/getting_started.htmlhttp://wiki.liftweb.net/http://github.com/dpp/liftweb

Lift Buch: „Exploring Lift“http://groups.google.com/group/the-lift-bookhttp://github.com/tjweir/liftbook/

46

Page 125: Jax2009 inovex-tjoch-lift-20090423

Exploring Lift Mail 2009, oder LyX Version!Derek Chen-Becker, Tyler Weir, Marius Danciu

Beginning ScalaMail 2009David Pollak

Programming in ScalaMartin Odersky, Lex Spoon, and Bill Venners

...47

Page 126: Jax2009 inovex-tjoch-lift-20090423

Tobias JochSystem ArchitectureProject Management

inovex GmbHKarlsruher Straße 7175179 Pforzheim

0173.3181 [email protected]

Fragen & Antworten

Wir nutzen Technologien, um unsere Kunden glücklich zu machen. Und uns selbst.

Page 127: Jax2009 inovex-tjoch-lift-20090423

Tobias JochSystem ArchitectureProject Management

inovex GmbHKarlsruher Straße 7175179 Pforzheim

0173.3181 [email protected]

Vielen Dank! ;)

Wir nutzen Technologien, um unsere Kunden glücklich zu machen. Und uns selbst.


Recommended