Icarus dynamic menu with more than ~9 entries not working

Post Reply
matrix
Posts: 6
Joined: 11 Aug 2016, 08:45

11 Aug 2016, 17:26

Hi,
I am using the latest Icarus (1.1) IcarusMenu in the form

Code: Select all

<pi:menu widgetVar="MatrixMenu" id="panelMenu_#{menubean.menuBarActiveItem.id}" model="#{menubean.panelMenu}"/>
where the menuModel is being generated dynamically from code using Primefaces org.primefaces.model.menu.DefaultMenuModel, org.primefaces.model.menu.DefaultMenuItem and org.primefaces.model.menu.DefaultSubMenu objects (This also means the defaultMenuModel.generateUniqueIds() is used for generation of element ids).

If the menu has more than ~9 top-level entries, the menu style breaks (subsequent menu items have wrong CSS style class "sidebar-submenuitem" instead of "sidebar-menuitem" which looks broken) due to IcarusMenuRenderer:70 and IcarusMenuRenderer:91 isParentRootMenu(String elementId) method calls in IcarusMenuRenderer:178.
This is due to this method, where the element id is checked for its length (something like return (elementId.trim().length() == 1)), which returns wrong results for elements having an id > 9.

This can be easily reproduced by generating a dynamic menu using the specified default menu model and primefaces menu item classes, where there are more than 9 top-level menu items.

User avatar
DarthMaul
Posts: 583
Joined: 23 Nov 2015, 21:20

15 Aug 2016, 08:41

Hi ,

We will review this and get back to you.

matrix
Posts: 6
Joined: 11 Aug 2016, 08:45

31 Aug 2016, 10:21

Our current workaround, which works fine for us at the moment:

Code: Select all

@Override
protected boolean isParentRootMenu(String elementId) {
  return (!elementId.contains(BaseMenuModel.ID_SEPARATOR));
}
It basically checks if an item's id separator (e.g. "_") is present in the id - if not, it should be a top-menu item [e.g. "13"], if it is present [e.g. "13_1", "14_2_1"], it is a sub-menu entry. It works fine with DefaultMenuItem and DefaultSubMenu, I am not sure it would also work with other types of MenuItems because the id generation may be different.

cagatay.civici
Prime
Posts: 18139
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

06 Sep 2016, 09:17

@Aragorn, please check this out.

aragorn
Posts: 3762
Joined: 29 Jun 2013, 12:38

23 Sep 2016, 10:24

Thanks for the fix, @matrix. I added it into next release. Github issue; https://github.com/primefaces/layouts/issues/115

Post Reply

Return to “Icarus”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest