The Ease of Angular with GWT
Join the DZone community and get the full member experience.
Join For FreeLet's see a quick example. Our framework builds with the standard GWT MVP, but we eliminated view and presenter interfaces. We are also relying on pure html templates, not gwt ui.xml-s or imperative UI building, but that's your choice.
Now let's say we have HTML template:
<span id="nameLabel"/> <button id="myButton">Clickme</button>
And in the ViewImpl class:
new LightLabel("#nameLabel") .bind(bindOnPresenter().get(Presenter._labelText)); new LightButton("#myButton") .bind(presenterMethod(Presenter.__buttonClicked));
And the Presenter (that's also the Activity):
@ObservableAttribute private String labelText; [...] @MethodRef public void buttonClicked() { setLabelText("You clicked me!"); }
Note a few things:
- The example framework uses html templates, but you're actually free to use your own solution in ViewImpl classes
- The ViewImpl class is dumb: it merely declares components and their bindings.
- The bindings are easy to express with the magically generated property and method literals , but it's still typesafe, compile-time checked.
- In this example the presenter is also the model (it contains the labelText), but that's also your choice, you can put it in a different Model class.
- The presenter works with the model only. Changes are automatically propagated to the view and vice-versa. There's no need of a view or presenter interface, and you don't have to manually propagate data to the view components and manually fetch them when you need them in the presenter. They're just there.
The magic I mentioned is performed by lombok-ds, our extension of lombok-pg. We are planning to switch to APT though.
Well, the above example is probably the most simple one. The github page contains more examples and principles to follow. We implemented an entire large-scale project with this approach, and it turned out to be pretty cool.
Please let us know if you're interested.
Ease (programming language)
AngularJS
Template
Express
Binding (linguistics)
Interface (computing)
Framework
Minimum viable product
APT (software)
Data (computing)
Opinions expressed by DZone contributors are their own.
Comments