One of the main features of a GWT application is, that you can write all your code in Java and do not need to care about HTML, CSS and JavaScript. All content can be loaded into the same div-element in one HTML-Standardpage. Sounds perfectly alright, but how do you navigate between different views, if for example you need a loginpage and don´t want the user to have access to your application before entering the right logindata?
Of course there is the possibility to have more than one HTML-Page in GWT as well, but if you want to do it the pure GWT-way, you can use a method to exchange the content on the page from inside your javacode.
In my latest GWT-application i used a switch-case statement in a java method to change the content on the page depending on the userstatus. I wanted to have three different views for the application. A loginview, a view to choose a database and open it and the main view of the application.
Add the HTML-Page
First of all i added a simple HTML-page with three divs in it for a header, a footer and the main content. These three divs will be filled with content from the java method „SetContent()“ that i will introduce below. The HTML-page is placed in the war-directory of the standard GWT „Web Application Project“ and looks as follows: