Hello
I’m trying to do a page with header and menu (left), like the image attachement
The classes i have are:
HEADER (always visible in top of page)
@HtmlImport("styles/shared-styles.html")
@SpringComponent
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class CabeceraView extends HorizontalLayout {
private ComboBox<String> combo = new ComboBox<>();
public CabeceraView() {
add(combo);
}
}
MainView (have header and menu, and the layout where “put” de others views)
@HtmlImport("styles/shared-styles.html")
@Route
@SpringComponent
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class MainView extends VerticalLayout implements RouterLayout{
public MainView() {
CabeceraView cabecera = new CabeceraView();
HorizontalLayout hl = new HorizontalLayout();
MenuView menu = new MenuView();
hl.add(menu);
add(cabecera,menu);
}
}
The Menu:
@HtmlImport("styles/shared-styles.html")
@Route("menu")
public class MenuView extends HorizontalLayout implements RouterLayout {
private Button button = new Button();
private Button button1 = new Button();
public MenuView() {
VerticalLayout vl = new VerticalLayout();
button.setText("Hola");
button.addClickListener(event->{
UI.getCurrent().navigate("hola");
});
button1.addClickListener(event->{
UI.getCurrent().navigate("amigo");
});
button1.setText("Amigo");
vl.add(button,button1);
add(vl);
}
}
Aand others 2 “views” to try the menu
@HtmlImport("styles/shared-styles.html")
@Route(value = "amigo", layout= MainView.class)
@SpringComponent
@ParentLayout(MenuView.class)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class AmigoView extends VerticalLayout {
public AmigoView() {
Label label = new Label("amigo");
add(label);
}
}
@HtmlImport("styles/shared-styles.html")
@Route(value = "hola", layout= MainView.class)
@SpringComponent
@ParentLayout(MenuView.class)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class HolaView extends VerticalLayout {
public HolaView() {
Label label = new Label("hola");
add(label);
}
}
361/5000
My problem is that I have never been able to put HolaView and AmigoView in the layout of the center, I always put down the MainView, and “playing” with Route.layout and ParentLayout the most I have achieved is that it works as I want, but losing the header .
Can someone tell me how is the correct “configuration” to work as I wish?
Thank you very much