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
Partner Zones AWS Cloud
by AWS Developer Relations
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
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Server-client Push with Vaadin

Server-client Push with Vaadin

Nicolas Fränkel user avatar by
Nicolas Fränkel
CORE ·
Oct. 26, 10 · Interview
Like (0)
Save
Tweet
Share
14.15K Views

Join the DZone community and get the full member experience.

Join For Free

I’m more and more committed to Vaadin since I see so many advantages to this solution. This time, I’ve investigated how to push server data to the client.

Vaadin is a general purpose framework that is wise enough not to force you to code in one way or another. Many features are available in the core distribution but many more are available in the add-ons directory. One such add-on let you add push feature to your simple application. This add-on is based on ICEPush technologies and is aptly named ICEPush add-on.

ICEPush is a brand of technology usable with both Java and JavaScript that uses long polling in order to achieve push and as such does not need port opening (save the one the standard HTTP stream uses, of course). The ICEPush Vaadin add-on integrates ICEPush into your Vaadin application in a very simple way, so that only so much steps are needed in order to develop a full-fledged application with push features.

Set-up ICEPush add-on

Once you’ve created your Vaadin project (and application), add the ICEPush libraries to your project. If you use Maven, just add the following snippet to your POM:

<dependency>
<groupId>org.vaadin.addons</groupId>
<artifactId>icepush</artifactId>
<version>0.2.0</version>
</dependency>

<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>

If not, just download the ZIP available in the directory. Beware that all JAR inside should be copied to your WEB-INF/lib. Even though 2 of them look alike, one is the ICEPush JAR, the other the integration layer on Vaadin.

Note: if you use the Vaadin plugin with your IDE, and it asks you to recompile your widgetset, just click yes and be done with it.

Use the right servlet

Replace the default servlet configured in your web.xml (probably com.vaadin.terminal.gwt.server.ApplicationServlet) with org.vaadin.artur.icepush.ICEPushServlet.

Add the ICEPush object to your window

In order to use push technology, you’ll have to add a new ICEPush object to the window in use, like so:

public class PushApplication extends Application {

private ICEPush push = new ICEPush();

@Override
public void init() {

Window mainWindow = new Window("Push Application Example");

mainWindow.addComponent(push);
}
}

Now, each time you nee to update the window, just call push.push() and it’s done!

This method call will update the client’s window with the update you made. Vaadin will do true AJAX in that it won’t reload the page, just update the view with the changes.

As usual, you’ll find the source of this article here, in Eclipse format.

To go further:

  • ICEPush technology site
  • ICEPush add-on page on Vaadin’s directory
  • A truly mystifying demo (as well as a real use case)

From http://blog.frankel.ch/server-client-push-with-vaadin

Vaadin push

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Host Hack Attempt Detection Using ELK
  • Documentation 101: How to Properly Document Your Cloud Infrastructure Project
  • Introduction Garbage Collection Java
  • Orchestration Pattern: Managing Distributed Transactions

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: