@Override protected void init(VaadinRequest vaadinRequest) { Navigator navigator = new Navigator(this, this); navigator.setErrorView(errorView); navigator.addProvider(viewProvider); setNavigator(navigator); }
@PostConstruct public void initialize() { if (ui.getNavigator() == null) { Navigator navigator = new Navigator(ui, ui); navigator.addProvider(viewProvider); navigator.setErrorView(errorView); } }
@Override protected void setup(VaadinRequest request) { Layout navigatorLayout = new VerticalLayout(); navigator = new Navigator(this, navigatorLayout); addComponent(navigatorLayout); navigator.addView(DEFAULT_VIEW_ID, new DefaultView()); navigator.addView(SECOND_VIEW_ID, new SecondView()); }
@Override protected void init(VaadinRequest request) { setTheme("valo"); getPage().setTitle("Aruba Networks"); MainView mainview = new MainView(); navigator = new Navigator(this, this); navigator.addView("login", new LoginView()); navigator.addView("main", mainview); // navigator.addView("Dataset1", new Dataset1View()); // navigator.addView("Dataset2",new Dataset2View()); navigator.navigateTo("main"); }
private void setupNavigator() { navigator = new Navigator(DemoUI.getCurrent(), content); registerViews(); // Add view change listeners so we can do things like select the correct menu item and update // the page title navigator.addViewChangeListener(navBar); navigator.addViewChangeListener(new PageTitleUpdater()); navigator.navigateTo(navigator.getState()); }
@Override protected void init(VaadinRequest request) { initViews(); initNavigator(); initDefaultUser(); navigator.navigateTo("login"); // First load is a login screen }
public MainView() { Navigator navigator = new Navigator(UI.getCurrent(), scroll_panel); navigator.addView(DashboardView.VIEW_NAME, DashboardView.class); navigator.addView(OrderView.VIEW_NAME, OrderView.class); navigator.addView(AboutView.VIEW_NAME, AboutView.class); if (navigator.getState().isEmpty()) { navigator.navigateTo(DashboardView.VIEW_NAME); } // menuButton1.addClickListener(event -> scroll_panel.setContent(new DashboardView())); // menuButton2.addClickListener(event -> scroll_panel.setContent(new OrderView())); // menuButton3.addClickListener(event -> scroll_panel.setContent(new AboutView())); menuButton1.addClickListener(event -> doNavigate(DashboardView.VIEW_NAME)); menuButton2.addClickListener(event -> doNavigate(OrderView.VIEW_NAME)); menuButton3.addClickListener(event -> doNavigate(AboutView.VIEW_NAME)); }
/** Registers av given view to the navigator and adds it to the NavBar */ private void addView(Class<? extends View> viewClass) { ViewConfig viewConfig = viewClass.getAnnotation(ViewConfig.class); switch (viewConfig.createMode()) { case ALWAYS_NEW: navigator.addView(viewConfig.uri(), viewClass); break; case LAZY_INIT: navigator.addProvider(new LazyProvider(viewConfig.uri(), viewClass)); break; case EAGER_INIT: try { navigator.addView(viewConfig.uri(), viewClass.newInstance()); } catch (Exception e) { e.printStackTrace(); } } navBar.addView(viewConfig.uri(), viewConfig.displayName()); }
/** * Internal initialization method, should not be overridden. This method is not declared as final * because that would break compatibility with e.g. CDI. * * @param request the initialization request * @param uiId the id of the new ui */ public void doInit(VaadinRequest request, int uiId) { if (this.uiId != -1) { throw new IllegalStateException("UI id has already been defined"); } this.uiId = uiId; // Actual theme - used for finding CustomLayout templates theme = request.getParameter("theme"); getPage().init(request); // Call the init overridden by the application developer init(request); Navigator navigator = getNavigator(); if (navigator != null) { // Kickstart navigation if a navigator was attached in init() navigator.navigateTo(navigator.getState()); } }
private void registerViews() { addView(HomeView.class); addView(LayoutView.class); addView(OrdersView.class); addView(AsyncOrdersView.class); addView(LazyOrdersView.class); addView(FormView.class); addView(SlowRenderingView.class); addView(HeapDestroyerView.class); navigator.setErrorView(ErrorView.class); }
@Override protected void init(VaadinRequest request) { setLocale(Locale.ENGLISH); // Let's register a custom error handler to make the 'access denied' messages a bit friendlier. setErrorHandler( new DefaultErrorHandler() { @Override 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); } } }); VerticalLayout layout = new VerticalLayout(); Panel viewContent = new Panel(); MenuBar menu = new MenuBar(); menu.addStyleName("navigation-menu"); layout.addComponents(menu, viewContent); layout.setSizeFull(); viewContent.setSizeFull(); layout.setExpandRatio(viewContent, 1); menu.addItem("Trading Area", e -> onDashboardClicked()); menu.addItem("Users", e -> onCustomersClicked()); navigator = new Navigator(this, viewContent); springViewProvider.setAccessDeniedViewClass(AccessDeniedView.class); navigator.addProvider(springViewProvider); navigator.setErrorView(ErrorView.class); setContent(layout); String state = navigator.getState(); if (state != null && !state.isEmpty()) { navigator.navigateTo(state); } else { navigator.navigateTo(TradingAreaView.NAME); } }
private void BuildNavigator() { navegador = new Navigator(parentUI, content); navegador.addView("/dashboard", DashboardView.class); for (String route : routes.keySet()) { navegador.addView("/" + route, routes.get(route)); } String f = Page.getCurrent().getUriFragment(); if (f != null && f.startsWith("!")) { f = f.substring(1); } if (f == null || f.equals("") || f.equals("/")) { navegador.navigateTo("/dashboard"); menu.getComponent(0).addStyleName("selected"); HelpManager.getInstance().showHelpFor(DashboardView.class); } else { navegador.navigateTo(f); HelpManager.getInstance().showHelpFor(routes.get(f)); viewNameToMenuButton.get(f).addStyleName("selected"); } navegador.addViewChangeListener( new ViewChangeListener() { @Override public boolean beforeViewChange(ViewChangeEvent event) { HelpManager.getInstance().closeAll(); return true; } @Override public void afterViewChange(ViewChangeEvent event) { View newView = event.getNewView(); HelpManager.getInstance().showHelpFor(newView); } }); }
public void checkAccessRestrictionForRequestedView(Navigator navigator) { final View targetView = viewProvider.getView(navigator.getState()); if (targetView != null) { final Collection<ConfigAttribute> attributes = new SecuredAnnotationSecurityMetadataSource() .getAttributes( new SimpleMethodInvocation( targetView, ReflectionUtils.findMethod( View.class, "enter", ViewChangeListener.ViewChangeEvent.class))); try { accessDecisionManager.decide( SecurityContextHolder.getContext().getAuthentication(), targetView, attributes); } catch (AccessDeniedException adExc) { // must be ignored as this exception is already handled in the AccessDecisionManager } } }
@Override public void buttonGo() { Navigator navigator = UI.getCurrent().getNavigator(); navigator.navigateTo("/inventorymanagement/" + function.VIEW_INVENTORY_CONSUMPTION); }
/** Initialize the navigator with all views */ private void initNavigator() { navigator = new Navigator(this, this); navigator.addViewChangeListener(new BackButtonController()); navigator.setErrorView(new ErrorView()); navigator.addView(LoginView.NAME_NAV, new LoginView()); navigator.addView(ChooseExamView.NAME_NAV, new ChooseExamView()); navigator.addView(AdministrationView.NAME_NAV, new AdministrationView()); navigator.addView(UserListView.NAME_NAV, new UserListView()); navigator.addView(UserImportView.NAME_NAV, new UserImportView()); navigator.addView(QuestionListView.NAME_NAV, new QuestionListView()); navigator.addView(DatabaseView.NAME_NAV, new DatabaseView()); navigator.addView(CategoryListView.NAME_NAV, new CategoryListView()); navigator.addView("RandomExam", randomExamView); navigator.addView("TakeExam", new TakeExamView()); }
private void onDashboardClicked() { navigator.navigateTo(TradingAreaView.NAME); }
private void onCustomersClicked() { navigator.navigateTo("users"); }