List of usage examples for com.vaadin.navigator Navigator setErrorView
public void setErrorView(final View view)
From source file:by.bigvova.MainUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { EventBus.register(this); getPage().setTitle("FoodNote"); UI.getCurrent().setLocale(Locale.forLanguageTag("ru-RU")); // Let's register a custom error handler to make the 'access denied' messages a bit friendlier. setErrorHandler(new DefaultErrorHandler() { @Override// ww w . ja v a 2 s . co m public void error(com.vaadin.server.ErrorEvent event) { if (SecurityExceptionUtils.isAccessDeniedException(event.getThrowable())) { Notification.show("Sorry, you don't have access to do that."); } else { super.error(event); } } }); HorizontalLayout layout = new HorizontalLayout(); layout.setSizeFull(); // By adding a security item filter, only views that are accessible to the user will show up in the side bar. sideBar.setItemFilter(new VaadinSecurityItemFilter(vaadinSecurity)); sideBar.setHeader(new CssLayout() { { Label header = new Label("<span>Food</span>Note", ContentMode.HTML); header.setWidth(100, Unit.PERCENTAGE); header.setHeightUndefined(); addComponent(header); addComponent(buildUserMenu()); } }); sideBar.getHeader().setStyleName("branding"); layout.addComponent(sideBar); CssLayout viewContainer = new CssLayout(); viewContainer.setSizeFull(); layout.addComponent(viewContainer); layout.setExpandRatio(viewContainer, 1f); Navigator navigator = new Navigator(this, viewContainer); // Without an AccessDeniedView, the view provider would act like the restricted views did not exist at all. springViewProvider.setAccessDeniedViewClass(AccessDeniedView.class); navigator.addProvider(springViewProvider); navigator.setErrorView(ErrorView.class); navigator.navigateTo(navigator.getState()); setContent(layout); // Call this here because the Navigator must have been configured before the Side Bar can be attached to a UI. }
From source file:com.before.vaadin.ui.MainUI.java
@Override public void init(VaadinRequest request) { VerticalLayout mainarea = new VerticalLayout(); Navigator navigator = new Navigator(this, mainarea); navigator.addProvider(viewProvider); navigator.setErrorView(CustomerView.class); setContent(new VerticalLayout(menu.getBasicMenu(), mainarea)); }
From source file:com.cerebro.provevaadin.Secure.java
public Secure() { HorizontalLayout top = new HorizontalLayout(); this.addComponent(top); top.addComponent(new Label("Area sicura")); VerticalLayout content = new VerticalLayout(); this.addComponent(content); Navigator nav = new Navigator(UI.getCurrent(), content); nav.setErrorView(new ErrorView()); nav.addView("", new HomeView()); nav.navigateTo(""); Button logout = new Button("Logout"); logout.addClickListener((Button.ClickEvent event) -> { System.out.println("Esco dalla sessione"); SecurityUtils.getSubject().logout(); UI.getCurrent().getSession().close(); UI.getCurrent().getPage().setLocation(""); });/*from w ww . j a va 2s.c o m*/ top.addComponent(logout); }
From source file:com.github.fbhd.AbstractSideBarUI.java
@Override protected void init(VaadinRequest vaadinRequest) { getPage().setTitle("fbhd"); final HorizontalLayout rootLayout = new HorizontalLayout(); rootLayout.setSizeFull();// www. java2 s . c om setContent(rootLayout); final VerticalLayout viewContainer = new VerticalLayout(); viewContainer.setSizeFull(); final Navigator navigator = new Navigator(this, viewContainer); navigator.setErrorView(new ErrorView()); navigator.addProvider(viewProvider); setNavigator(navigator); rootLayout.addComponent(getSideBar()); rootLayout.addComponent(viewContainer); rootLayout.setExpandRatio(viewContainer, 1.0f); }
From source file:com.github.moscaville.contactsdb.AbstractSideBarUI.java
License:Apache License
@Override protected void init(VaadinRequest vaadinRequest) { getPage().setTitle("ContactsDb"); final HorizontalLayout rootLayout = new HorizontalLayout(); rootLayout.setSizeFull();// w w w . j a v a 2 s. co m setContent(rootLayout); final VerticalLayout viewContainer = new VerticalLayout(); viewContainer.setSizeFull(); final Navigator navigator = new Navigator(this, viewContainer); navigator.setErrorView(new ErrorView()); navigator.addProvider(viewProvider); setNavigator(navigator); rootLayout.addComponent(getSideBar()); rootLayout.addComponent(viewContainer); rootLayout.setExpandRatio(viewContainer, 1.0f); }
From source file:com.logs.mavfun2.ExampleUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { Navigator navigator = new Navigator(this, this); navigator.addViewChangeListener(this); navigator.addView("", LoginView.class); if (SecurityUtils.getSubject().isAuthenticated()) { getUI().getNavigator().addView("secure", SecureView.class); }/* w ww. j ava 2 s . co m*/ navigator.setErrorView(ErrorView.class); }
From source file:com.mcparland.john.vaadin_mvn_arch.samples.MainScreen.java
License:Apache License
public MainScreen(MyUI ui) { setStyleName("main-screen"); CssLayout viewContainer = new CssLayout(); viewContainer.addStyleName("valo-content"); viewContainer.setSizeFull();/*w w w. ja v a2 s . c o m*/ final Navigator navigator = new Navigator(ui, viewContainer); navigator.setErrorView(ErrorView.class); menu = new Menu(navigator); menu.addView(new SampleCrudView(), SampleCrudView.VIEW_NAME, SampleCrudView.VIEW_NAME, FontAwesome.EDIT); menu.addView(new AboutView(), AboutView.VIEW_NAME, AboutView.VIEW_NAME, FontAwesome.INFO_CIRCLE); navigator.addViewChangeListener(viewChangeListener); addComponent(menu); addComponent(viewContainer); setExpandRatio(viewContainer, 1); setSizeFull(); }
From source file:fr.amapj.view.engine.menu.MenuPart.java
License:Open Source License
public void buildMainView(final AmapUI ui, ValoMenuLayout root) { root.prepareForMainPage();/*from w ww .ja v a2 s.co m*/ viewNameToMenuButton = new HashMap<String, Button>(); CssLayout menu = new CssLayout(); CssLayout menuItemsLayout = new CssLayout(); if (ui.getPage().getWebBrowser().isIE() && ui.getPage().getWebBrowser().getBrowserMajorVersion() == 9) { menu.setWidth("320px"); } // Chargement de tous les menus accesibles par l'utilisateur // et cration du "navigator" List<MenuDescription> allMenus = MenuInfo.getInstance().getMenu(); Navigator nav = new Navigator(ui, root.getContentContainer()); nav.addViewChangeListener(new ViewChangeListener() { @Override public boolean beforeViewChange(ViewChangeEvent event) { logger.info("Entre dans l'cran {}", event.getViewName()); return true; } @Override public void afterViewChange(ViewChangeEvent event) { menu.removeStyleName("valo-menu-visible"); } }); if (allMenus.size() > 0) { MenuDescription first = allMenus.get(0); nav.setErrorView(first.getViewClass()); } for (MenuDescription mD : allMenus) { nav.addView("/" + mD.getMenuName().name().toLowerCase(), mD.getViewClass()); } // Cration du menu root.addMenu(buildMenu(menu, menuItemsLayout, allMenus, nav, ui)); }
From source file:io.fns.calculator.Application.java
License:Apache License
@Override protected void init(VaadinRequest vaadinRequest) { Navigator navigator = new Navigator(this, this); navigator.setErrorView(errorView); navigator.addProvider(viewProvider); setNavigator(navigator);/* w w w .j a v a 2 s .c om*/ }
From source file:net.gvcc.jgoffice.MainUI.java
License:Open Source License
@Override protected void init(VaadinRequest request) { Navigator loginNavigator; getPage().setTitle("jGOffice"); initLayoutBeforLogin();//from www . j a v a 2 s . c om loginNavigator = new Navigator(this, loginLayout); loginNavigator.setErrorView(new ErrorPage()); loginNavigator.addView("LoginView", new LoginView()); loginNavigator.navigateTo("LoginView"); loginNavigator.addViewChangeListener(this); }