Help About Login please.

Hi all:

I need you to be my first login window and contains no top menu , because the menu must be visible one you see the user has logged in , appreciate me say that things must change to achieve the desired result.

I leave my current code below.

MyUI

[code]
package com.vaadin.ricardo.proyecto.logintest;

import javax.servlet.annotation.WebServlet;

import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.annotations.Widgetset;
import com.vaadin.navigator.Navigator;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.MenuBar;
import com.vaadin.ui.MenuBar.MenuItem;
import com.vaadin.ui.Panel;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
@Theme(“mytheme”)
@Widgetset(“com.vaadin.ricardo.proyecto.logintest.MyAppWidgetset”)
public class MyUI extends UI {

@Override
protected void init(VaadinRequest vaadinRequest) {
    VerticalLayout layout = new VerticalLayout();
    MenuBar menu=new MenuBar();
    menu.setSizeFull();
    MenuItem mnuArchivo=menu.addItem("File", null);
    MenuItem mnuSalir=mnuArchivo.addItem("Close Sesion", null);
    MenuItem mnuModule=menu.addItem("Modules", null);
    MenuItem mnuWindowsOne=mnuModule.addItem("Windows One", null);
    MenuItem mnuWindowsTwo=mnuModule.addItem("Windows Two", null);
    layout.addComponent(menu);
    Panel p=new Panel("Modules");
    Navigator nav=new Navigator(this,p);
    layout.addComponent(p);
    setContent(layout);
   
    //nav.addView("", MainView.class);
    nav.addView("", LoginView.class);
    nav.addView(LoginView.NAME, LoginView.class);
    nav.addView(WindowsOne.NAME, WindowsOne.class);
    nav.addView(WindowsTwo.NAME, WindowsTwo.class);
    mnuSalir.setCommand(new MenuBar.Command() {
        @Override
        public void menuSelected(MenuBar.MenuItem selectedItem) {
            MyUI.getCurrent().getNavigator().navigateTo("login");
        }
    });
    mnuWindowsOne.setCommand(new MenuBar.Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            MyUI.getCurrent().getNavigator().navigateTo("menuOne");
        }
    });
    mnuWindowsTwo.setCommand(new MenuBar.Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            MyUI.getCurrent().getNavigator().navigateTo("menuTwo");
        }
    });
}

@WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
@VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
public static class MyUIServlet extends VaadinServlet {
}

}
[/code]LoginView

package com.vaadin.ricardo.proyecto.logintest;

import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.PasswordField;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
public class LoginView extends VerticalLayout implements View{
     public static final String NAME="login";
   FormLayout form=new FormLayout();
    public LoginView(){
        TextField txtUsername=new TextField("UserName");
        PasswordField txtPassword=new PasswordField("Password");
        form.addComponent(txtUsername);
        form.addComponent(txtPassword);
        Button btn=new Button("Log In");
        this.addComponent(form);
        this.addComponent(btn);
       
         
    }

    @Override
    public void enter(ViewChangeListener.ViewChangeEvent event) {
    }
    
}

WindowsOne

package com.vaadin.ricardo.proyecto.logintest;

import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
public class WindowsOne extends VerticalLayout implements View{
    public static final String NAME="menuOne";
    public WindowsOne(){
        this.addComponent(new Label("THIS IS MY WINDOWS ONE"));
    }

    @Override
    public void enter(ViewChangeListener.ViewChangeEvent event) {
  
    }
}


WindowsTwo

package com.vaadin.ricardo.proyecto.logintest;

import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
public class WindowsTwo extends VerticalLayout implements View{
    public static final String NAME="menuTwo";
    public WindowsTwo(){
        this.addComponents(new Label("This is my windows two"));
    }

    @Override
    public void enter(ViewChangeListener.ViewChangeEvent event) {
  
    }
    
}

Any plz :(…

Hi,

please check out the dashboard demo code at
https://github.com/vaadin/dashboard-demo/blob/master/src/main/java/com/vaadin/demo/dashboard/DashboardUI.java
. It has a quite similar use case. In short the login view vs main view change is handled by the UI class, and the navigator only handles view changes once the user has logged in.

-tepi

Not found for my example :(.

The problem are public Navigator nav = new Navigator(this, panel); , my component ever are in the Panel :(…
i need the login out off Panel