Gwt development with errai and forge

22

description

Talk di Luca Masini alla DevFest 2012 @ Firenze

Transcript of Gwt development with errai and forge

Page 1: Gwt development with errai and forge
Page 2: Gwt development with errai and forge

GDG FirenzeLuca Masini

Page 3: Gwt development with errai and forge

GWT development with Errai and Forge

How to use the same development model on client/server with Errai/Forge

Page 4: Gwt development with errai and forge

Why GWT ?

● With the arise of AJAX and Web 2.0 GWT is the only tool that allows a single programming language on client and server

● The problem is that the development environments (API and platform) are really different

Page 5: Gwt development with errai and forge

Here comes Errai

With Errai you can use a single model to

develop all your applications: Java EE 6 with its

CDI capabilities and its RESTful services

Page 6: Gwt development with errai and forge

Optional Modules

● Automatic Data Binding between POJOs and UI

● A template system that is far better than UIBinder

● JPA for the WebSQL DB

● Also.....an optional simple and powerful bidirectional Message Bus between the client and the server

Page 7: Gwt development with errai and forge

And what about Forge ?

When you start a new project you can:

● start from scratch, googling for configuration and the initial code skeleton

● use a Maven Archetype (not really interactive)

● use JBoss Forge to create the scaffold that you really need in your project

Page 8: Gwt development with errai and forge

Forge: developer's BASH

● It creates only applications that use standard technologies (Java language, Java EE programming model)

● No Forge APIs or configuration files on your code

● Once your project is configured, you can forget about Forge, or may use it as your dev shell, your taste

Page 9: Gwt development with errai and forge

Forge helps us: scaffolding

Page 10: Gwt development with errai and forge

CDI with Errai unveiled

● Create a GWT's EntryPoint with a simple bean and the @EntryPoint annotation

● The @PostConstruct method will instruct how to bootstrap your application

● You can do communication over the Errai Bus using only CDI event○ client code○ server code

Page 11: Gwt development with errai and forge

CDI with Errai unveiled

Page 12: Gwt development with errai and forge

Errai JAX-RS

● Forge helps us creating the jax-rs setup

● You can call a RESTful end-point only using jax-rs API within the CDI container

● You can use a Jackson-compatible marshalling/unmarshalling JSON

Page 13: Gwt development with errai and forge

Errai JAX-RS

Page 14: Gwt development with errai and forge

Errai UI

● Put your HTML5 template into your Java packages

● Annotate your Composite with @Templated and you are done!

● You can also inject Widgets inside the template and of course attach event to those widgets

Page 15: Gwt development with errai and forge

Errai Data Binding

● A POJO annotated with @Bindable can be injected into a Composite as a DataBinder

● When the Composite is annotated with @Templated then the binding betweeen fields and widgets is implicit

● We can also register a custom Converter, global or local to a property

Page 16: Gwt development with errai and forge

Errai UI and DataBinding

Page 17: Gwt development with errai and forge

Errai's Portable Objects

● We mark objects that need to travel between client and server with the @Portable annotation

● Many strategies for construction and injection

● Same API on client and on server

Page 18: Gwt development with errai and forge

Conclusions

● Forge helps us tailoring new projects for our needs and working in a productive way on existing ones

● Errai lets us write less and better code with a common paradigm between client and server

● Errai has also many addional modules that complete our client coding experience (HTML5 UI, Data Bindind, RESTful client)

Page 19: Gwt development with errai and forge

References

● The History and Future of GWT: http://go o.gl/mwrOJ

● Innovation Award 2012, JBoss Forge: http://jax-awards.com/proposal_technology.php?id=599&show=more

● Errai's project leader in the GWT Steering Committee: http://googlewebtoolkit.blogspot.it/2012/09/gwt-survey.html

Page 20: Gwt development with errai and forge

Q&A

Page 21: Gwt development with errai and forge

<Thank You!>

Page 22: Gwt development with errai and forge