-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding elements to AppLayout object dynamically #44
Comments
Simply don't build the Layout right away, actually use the Builder pattern. Instead of doing this:
Do this:
But you have a point the Builder pattern and the resulting AppLayout do require some refactoring. The NPE is not supposed to happen, also your code is supposed to work, but currently it doesn't. 😞 I opened Issue #45 to make things more clear |
Thanks, that worked, sort of. I came across another thing, however: It looks like there's a limit of four submenu items, although I didn't find that value in the code yet. What I'm trying: for (int i = 1; i < 10; i++) {
if (i == 3 || i == 7) {
SubmenuBuilder submenu = SubmenuBuilder.get("Menu "+i,VaadinIcons.MENU);
for (int j = 1; j < 7; j++) {
submenu.add("Submenu "+j,View2.class);
System.out.println("Submenu "+j);
}
builder.add(submenu.build());
} else {
builder.add("Menu " + i, VaadinIcons.ADJUST, View1.class);
}
} So I'm expecting 6 submenu items on top level menu 3 and 7, but both have only 4. Nothing on the console, my println counts from 1 to 6 as expected. Cheers André PS: Thanks for all that, I really appreciate it! |
I did this for you now thank you for your finding! The Issue is occurring because the value for the max-height amination I have set is too small for your elements to fit. Here a temporary fix which you can add to your theme file:
|
Sorry, I'm late ;) Thaks a ton, highly @appreciated ;) |
Hi!
Is there a way to add elements, like menu items and submenus, dynamically? I'd like to loop over an array after I created the AppLayout object and add items one by one.
I tried many things, for example this:
Line 2 and 3 work, but
addNavigationElement
throws a null pointer exception.Any idea appreciated!
Cheers
André
The text was updated successfully, but these errors were encountered: