Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Vaadin+Scala
Why?- Simple programming model- Secure- No javascript- Beautiful
Simple programming model- Abstracted from HTTP- No request/response/session mess- All AJAX- Just a web page
Secure- All server-side- Validations- No code on client- CSRF, XSS protection built-in
No javascript- No bad parts- Good parts still accessible- Built on GWT- Large test suite for each browser
Beautiful- Mature codebase- Thinking of U and I- Widgets and addons- Themes
Performance- Almost every event is handled on server- Optimized wire format- No page reload- Static content
Performance vs PrimeFaces
Scalability Study - QuickTickets
+Scalamandatory ugly java slide
+Scala6    class TransactionPage(controller:TransactionController=new TransactionController) extends BasePage{7     model....
+Scaladin- wraps Vaadin api into idiomatic Scala- closures, Options, etc.
+Scala => declarative- comparable to JSON1   {"transactionPage": {2    "controller": "TransactionController",3    "composi...
+Scala => inline constructorsclass TransactionPage(controller: TransactionController = new TransactionController) extends ...
+Scala => DelayedInit8      trait BasePage extends CustomComponent with Validations   with DelayedInit   {9       var para...
+Scala => callbacks and HOFsButton(start, validated(form)(controller.start(done)))def apply(caption: String, clickListener...
+Scala => symbols- localization- natural namescaption = helloimplicit def translateSymbol(s: Symbol) = s"${s.name} locale:...
+Scala => structural types- navigate in nested objectsval form = new Form {      val beanItem = new BeanItem(model) {...fo...
+JRebel- Reloading classes as if they were templates- Free for Scala- Free for Vaadin Pro users
Thank you!    Q&A
Upcoming SlideShare
Loading in …5
×

Vaadin+Scala

4,787 views

Published on

Slides of the talk by Oleg Aleshko on Vaadin and Scala at scalaby#10

  • Be the first to comment

Vaadin+Scala

  1. 1. Vaadin+Scala
  2. 2. Why?- Simple programming model- Secure- No javascript- Beautiful
  3. 3. Simple programming model- Abstracted from HTTP- No request/response/session mess- All AJAX- Just a web page
  4. 4. Secure- All server-side- Validations- No code on client- CSRF, XSS protection built-in
  5. 5. No javascript- No bad parts- Good parts still accessible- Built on GWT- Large test suite for each browser
  6. 6. Beautiful- Mature codebase- Thinking of U and I- Widgets and addons- Themes
  7. 7. Performance- Almost every event is handled on server- Optimized wire format- No page reload- Static content
  8. 8. Performance vs PrimeFaces
  9. 9. Scalability Study - QuickTickets
  10. 10. +Scalamandatory ugly java slide
  11. 11. +Scala6 class TransactionPage(controller:TransactionController=new TransactionController) extends BasePage{7 model.params = params8 compositionRoot = new VerticalLayout {9 val form = new Form {10 caption = hello11 val beanItem = new BeanItem(model) {12 item = this13 visibleItemProperties = propertyIds().filter(_ != "progress")14 }15 field("price").foreach { p =>16 p.required = true17 p.validators += >=(10.0)18 }19 }20 components ++=21 Button(check, Notification.show(model.toString)) ::22 Button(start, validated(form)(controller.start(done))) ::23 form ::24 new ProgressIndicator {property = form.beanItem.property("progress")} ::25 Nil26 }27 def done = Notification.show(done, Type.Tray)28 def model = controller.model29 }
  12. 12. +Scaladin- wraps Vaadin api into idiomatic Scala- closures, Options, etc.
  13. 13. +Scala => declarative- comparable to JSON1 {"transactionPage": {2 "controller": "TransactionController",3 "compositionRoot": {4 "type": "VerticalLayout",5 "components": [6 {7 "type": "Button",8 "caption": "hello"....9 }10 ]11 }12 }}- no need to reference view from controller- statically checked- support for HTML templates
  14. 14. +Scala => inline constructorsclass TransactionPage(controller: TransactionController = new TransactionController) extends BasePage {//body goes here}
  15. 15. +Scala => DelayedInit8 trait BasePage extends CustomComponent with Validations with DelayedInit {9 var params: String = ""...16 def init(params: String) = {17 this.params = params18 initCode.foreach(_())19 }20 }14 case class TabView(name: String)(content: => Seq[Component] = stubContent(name))15 extends VerticalLayout with View {16 def enter(event: ViewChangeEvent) {17 //showing that state persists and lazy loading is possible18 val params = event.getParameters19 content.collect {20 case page: BasePage => add(page).init(params)21 case view => add(view)22 }23 Notification.show("Entered " + name + " with params " + params)24 }25 }class TransactionPage(controller: TransactionController = new TransactionController) extends BasePage { model.params = this.params
  16. 16. +Scala => callbacks and HOFsButton(start, validated(form)(controller.start(done)))def apply(caption: String, clickListener: => Unit): Buttondef validated(form: Form)(action: => Unit)def start(done: => Unit)- increase code reuse- decrease coupling
  17. 17. +Scala => symbols- localization- natural namescaption = helloimplicit def translateSymbol(s: Symbol) = s"${s.name} locale:${self.locale}"implicit def translateTuple[T](s: (Symbol, T)) (implicit toParams: T => TranslationParams) =translateSymbol(s._1).format(toParams(s._2).p: _*)validators += >=(10.0) def >=[T](bound: T)(implicit ord: Ordering[T]): Option[Any] => Validation = { import ord._; v => v match { case Some(v: T) if v >= bound => Valid case _ => Invalid(Symbol("should be greater %s") -> bound :: Nil) } }
  18. 18. +Scala => structural types- navigate in nested objectsval form = new Form { val beanItem = new BeanItem(model) {...form.beanItem.property("progress")- eliminate dependenciestrait Translation {self: {def locale: Option[Locale]} =>
  19. 19. +JRebel- Reloading classes as if they were templates- Free for Scala- Free for Vaadin Pro users
  20. 20. Thank you! Q&A

×