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

Trending

  • Why You Should Consider Using React Router V6: An Overview of Changes
  • How To Use an Automatic Sequence Diagram Generator
  • Security Challenges for Microservice Applications in Multi-Cloud Environments
  • How AI Will Change Agile Project Management

Trending

  • Why You Should Consider Using React Router V6: An Overview of Changes
  • How To Use an Automatic Sequence Diagram Generator
  • Security Challenges for Microservice Applications in Multi-Cloud Environments
  • How AI Will Change Agile Project Management
  1. DZone
  2. Data Engineering
  3. Data
  4. Obtaining Request Data in Vaadin 7

Obtaining Request Data in Vaadin 7

Nicolas Fränkel user avatar by
Nicolas Fränkel
CORE ·
Mar. 12, 12 · Interview
Like (0)
Save
Tweet
Share
9.89K Views

Join the DZone community and get the full member experience.

Join For Free

I confess, Vaadin 6 was good, but Vaadin 7 is even better. This article will detail most nastiness that is managed by this new version so that we only have to code a few lines to achieve our goals. One of such goal is the search of information about the request and the client.

In Vaadin 6, it was possible, but cumbersome for we had to force our application to implement the HttpServletRequestListener interface. The interface let us access the servlet request (as well as the servlet response), and then we were on our own.

In Vaadin 7, the Vaadin team identified recurring needs to some piece of data and provided a Vaadin API to access them easily; for example:

  1. The user agent type and its version (major and minor)
  2. The user's locale to initialize resources bundles
  3. The screen size, as well as the underlying viewpoint size to adapt the layour to the available space
  4. The URL fragment (#) to restore data

Vaadin 7 Root's init() method takes a WrapperRequest as a parameter, that is the entry point into these informations. Behold how we could address the above needs:

public class Vaadin7Root extends Root {
 
    @Override
    public void init(WrappedRequest wrapped) {
 
        BrowserDetails details = wrapped.getBrowserDetails();
 
        WebBrowser browser = details.getWebBrowser();
 
        // Need #1
        browser.getBrowserApplication();    // User agent
        browser.getBrowserMajorVersion();   // Major version
        abrowser.getBrowserMinorVersion();  // Minor version
 
        // Need #2
        browser.getLocale();                // User locale
         
        // Need #3
        browser.getClientHeight();          // Browser height
        browser.getClientWidth();           // Browser width
        browser.getScreenHeight();          // Viewpoint height
        browser.getScreenWidth();           // Viewpoint width
 
        // Need #4
        details.getUriFragment());          // URI fragment
    }

} 

 No more dirty plumbing into the ServletRequest, welcome to a world of easy reading!

The ready-to-use WAR file is available here (sources included).

Note: There's a large difference in behavior between version 6 and 7 of Vaadin. In Vaadin 7, refreshing the browser will cause the init() method to be called again. 

Vaadin Data (computing) Requests

Published at DZone with permission of Nicolas Fränkel, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • Why You Should Consider Using React Router V6: An Overview of Changes
  • How To Use an Automatic Sequence Diagram Generator
  • Security Challenges for Microservice Applications in Multi-Cloud Environments
  • How AI Will Change Agile Project Management

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

Let's be friends: