Class Application

java.lang.Object
com.storedobject.vaadin.Application
Direct Known Subclasses:
Application

public abstract class Application extends Object
Application is the base class for creating a 'single page' web applications. The 'single page' should be defined by extending ApplicationView class.
 
 public class Demo extends Application {

   @Override
   protected ApplicationLayout createLayout() {
     return new AppFrame();
   }

   private static class AppFrame extends ApplicationFrame {

     @Override
     public void drawMenu(Application application) {
       setCaption("Sample Application  Ver 1.0.4");
       addToNavbar(new SpeakerButton());
       ApplicationMenu menu = getMenu();
       ApplicationMenuItem ami;
       ami = application.createMenuItem("One", () -> Notification.show("Hello World!"));
       menu.add(ami);
       ami = application.createMenuItem("Two", () -> Notification.show("Hello World 2!"));
       menu.add(ami);
       ami = application.createMenuItem("Greeting", () -> {
         Application a = Application.get();
         a.speak("Hello, how are you?");
         if(!a.isSpeakerOn()) {
           Notification.show("Speaker is off! Click on the speaker button to turn it on.");
         }
       });
       menu.add(ami);
     }
   }

   @Route("")
   public static class AppView extends ApplicationView {

     @Override
     protected Application createApplication() {
       return new Demo();
     }
   }
 }
 
 
The 'single page' can be any layout component that implements the interface ApplicationLayout. The layout typically contains a 'menu' area and 'content' area. One can use Vaadin's AppLayout or similar components as the base for this. The 'menu' area will contain ApplicationMenuItem instances and when a 'menu item' is clicked, the Runnable action associated with it will be executed. One may associate any Runnable action with a 'menu item' such as generating a report or invoking a View. If a View is invoked, its associated 'view component' is displayed in the 'content' area and its 'caption' is inserted as a new 'menu item' in the 'menu' area. The 'content' area displays only the 'active view' (currently selected or executed view) and hides all previously displayed 'views' but any of those 'views' can be made active again by licking on its respective 'menu item' created from its 'caption'.
Author:
Syam