GWT: 0 to 60mph in no time, Chris Ramsdale
June 25th, 2010 by joachim
JBossWorld Boston notes, GWT: 0 to 60mph in no time, Chris Ramsdale
From 25000ft
- toolkit, not fframework
- code in java, run as JavaScript
- one codebase, any browser
- makes AJAX a pice of cake and faster
- used in many Google projects like Google Wave and AdWords
Family
- SDK, compiler, generator
- eclipse plug-in
- speed tracer
Focus on users
- Our users, Developers
– leverage existing IDEs and tools
– minimize refresh time between code changes
– automate where possible
- Your users, Customers
– minimize startup time
– make it a comfortable experience
– allow them to select the browser
Java to JavaScript compiler, right?
- compiling to JavaScript instead of compiling to Assembler?
- You can pretty print if needed
From code to deployment
Generators
- provide power behind your GWT app
Ajax helper
Creating UIs
Goals
- utilize common devevelopment practices
- minimize boilerplate code
- remove a few frustrations along the way
uiBinder XML with
Linker
- different ways of loading the JavaScript
Use “-gen” to display the generated code
Tips and tricks
- Reduce optimizations, reduce compile time
– -draftCompile : skip all optimizations, development only
Optimize for user
- bundle resources
- split code
interface Bla extends ClientBundle {
@Source("Contexts.css)
public ContactCss contextCss()
@Source("Contexts.gif)
public ClientImage contextImage()
}
insert runAsync for code splitting
@UiHandler("showImagesButton")
void onOkClicked(ClickEvent event) {
GWT.runAsync(new RunAsyncCallback() {
public void onSuccess() {
showImagesDialog()
}
}
}
“direct” approach
Write a bunch of widgets with self-contained logic
- hard to test - need GWTTestCase
- mocks not encouraged - harder to write smaller tests
- platform specific UI code - limits code reuse
- Too any dependencies, difficult to optimize
MVP approach
Cast
- model - DTOs and business logic
- View - the display
- Presenter - application logic
Goals
- be practical
- avoid rigid patters
- put complex login in presenters
MVP vs MVC
- C = view contains event logic
- P = render logic + event logic, separate view
You only have to test the model and presenter, rest is GWT itself and tested by Google
Technology interoperability
- Seam
- JSF
- G4JSF
Making the cloud a reality







