DZone
Java Zone
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
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > Switching Windows in Vaadin

Switching Windows in Vaadin

Nicolas Fränkel user avatar by
Nicolas Fränkel
CORE ·
Mar. 09, 12 · Java Zone · Interview
Like (0)
Save
Tweet
5.38K Views

Join the DZone community and get the full member experience.

Join For Free

In my last article, I definitely advised that when needing to radically change components displayed on the screen, you need to switch the main window's contents - the view - and not the window itself.

Fortunately, this confusion is not possible anymore in Vaadin 7 since the application object and the main window are merged into the Root class.

package com.morevaadin.vaadin7.example;
 
import com.vaadin.terminal.WrappedRequest;
import com.vaadin.ui.Label;
import com.vaadin.ui.Root;
import com.vaadin.ui.VerticalLayout;
 
@SuppressWarnings("serial")
public class Vaadin7RootApplication extends Root {
 
    @Override
    protected void init(WrappedRequest request) {
 
        VerticalLayout layout = new VerticalLayout();
 
        layout.setMargin(true);
 
        Label label = new Label("Hello Vaadin user");
 
        layout.addComponent(label);
 
        setContent(layout);
    }
}

Note that Root instances have no root content (!): this means we have to set it explicitly, like the layout in the previous snippet.

As a corollary, this also means a Root class has to be configured in the web deployment descriptor for the Vaadin servlet (and not an Application class anymore). This directly translates into the following snippet:

...
<servlet>
    <servlet-name>Vaadin 7 Root Example</servlet-name>
    <servlet-class>
        com.vaadin.terminal.gwt.server.ApplicationServlet
    </servlet-class>
    <init-param>
        <param-name>root</param-name>
        <param-value>
            com.morevaadin.vaadin7.example.Vaadin7RootApplication
        </param-value>
    </init-param>
</servlet>
...

Conclusion: Vaadin 7 is less confusing than Vaadin 6 for managing full-screen windows. Besides, it achieves the same result in as many lines of code: it's a definite step toward cleaner windows management.

The archive that highlights the above code can be downloaded here.

Note: At the time of this writing, the Eclipse Vaadin plugin doesn't check the Vaadin version and generates the application skeleton adapted to Vaadin 6. Expect to see this corrected with Vaadin 7 release.

 

Vaadin

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • API Security Tools: What To Look For
  • Python Class Attribute: Class Attribute vs. Instance Attribute
  • NextJS Vs React: Key Differences, Advantages and Limitations
  • Revoking Access to JWTs With a Blacklist/Deny List

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • 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:

DZone.com is powered by 

AnswerHub logo