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. Software Design and Architecture
  3. Integration
  4. Preserving State Between Refreshes

Preserving State Between Refreshes

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

Join the DZone community and get the full member experience.

Join For Free

Last week, we had a look at the new Vaadin 7 Root that takes the place of the old version 6 Window. Though this evolution cleans window management in version 7, it brings a change that can have important consequences for those unaware of it.

In Vaadin 7, state is not kept between refreshes, whereas in v6, it was. Anyway, this is only the default behavior, and the Vaadin team provides us with the mean to do as we please. The only thing to do is to get a handle on the Application instance behind the root and call the preserveRoot(boolean) method, like so:

public class Vaadin7Root extends Root {
 
    public void init(WrappedRequest wrapped) {
 
        getApplication().setRootPreserved(true);
    }
}

You can find here the sources of a little example application that let us play with this behavior. Let's try some things:

  1. Call the URL with a named fragment beneath it (like #test). The page displays it right of the URI fragment label.
  2. Change the fragment in the adress bar (like #testchanged) and refresh the page. The page should display the new URI fragment in the page.
  3. Now, check the Preserve root checkbox. Change the fragment for the second time (like #testsecond) and behold, the page still displays the "testchanged" value.

Whatever you want the behavior to be, Vaadin provides it :-)

Fragment (logic) Vaadin application Uniform Resource Identifier teams Label

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

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Keep Your Application Secrets Secret
  • Fargate vs. Lambda: The Battle of the Future
  • Introduction To OpenSSH
  • The 5 Books You Absolutely Must Read as an Engineering Manager

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: