DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Coding
  3. Frameworks
  4. The Ease of Angular with GWT

The Ease of Angular with GWT

Gabor Farkas user avatar by
Gabor Farkas
·
May. 01, 14 · Interview
Like (1)
Save
Tweet
Share
5.95K Views

Join the DZone community and get the full member experience.

Join For Free

Let'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.

Popular on DZone

  • Exploring the Benefits of Cloud Computing: From IaaS, PaaS, SaaS to Google Cloud, AWS, and Microsoft
  • How To Use Terraform to Provision an AWS EC2 Instance
  • Choosing the Best Cloud Provider for Hosting DevOps Tools
  • Key Considerations When Implementing Virtual Kubernetes Clusters

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: