-
1. Re: how to set HtmlPanelMenuItem as selected
danielk Jan 7, 2009 5:38 AM (in response to janson12)You have to walk through your PanelMenu and expand each Node (Group) that is on the path to the wanted leaf (Item). For the last Group which has the leaf as child, you can call:
myHtmlPanelMenu.setSelectedChild(childItemName);
Hollywood principal, dont call us we call you. So Parent can say which is the current selected Item. The Item itself knows nothing.
Hope i can help a little bit,
DanielK -
2. Re: how to set HtmlPanelMenuItem as selected
danielk Jan 7, 2009 5:41 AM (in response to janson12)Ohh sry (need an edit mode in this forum), you have to call this method for HtmlPanelMenu after expanding all needed Groups. And set setSelectedChild() for HtmlPanelMenu not the last group. "myPanelMenu" is from Type HtmlPanelMenu, so just ignore the last part of my first sentence ,D
-
3. Re: how to set HtmlPanelMenuItem as selected
janson12 Jan 7, 2009 5:56 AM (in response to janson12)Hi Daniel,
thanks for the quick response. i could manage to open the right group but somehow the previously selected Group is still marked with italics. what i've done is this:for (int i=0; i<menuGroupList.size(); i++) { panelMenuGroup = (HtmlPanelMenuGroup) menuGroupList.get(i); if (panelMenuGroup.getId().equals("targetGroup")) { panelMenuGroup.setExpanded(true); menu.setSelectedChild("itemToBeSelected"); } }
Unfortunately this doesn't change anything of the "itemToBeSelected" style.
Do i miss something? -
4. Re: how to set HtmlPanelMenuItem as selected
danielk Jan 7, 2009 6:53 AM (in response to janson12)Have you called before something like this:
HtmlPanelMenuItem item = new HtmlPanelMenuItem(); item.setName("itemToBeSelected");
Perhaps name is wrong or not set to HtmlPanelMenuItem? -
5. Re: how to set HtmlPanelMenuItem as selected
janson12 Jan 7, 2009 7:07 AM (in response to janson12)in fact i assigned ids. oddly enough when i call
String selected = menu.getSelectedChild();
the correct id is returned. i've also assigned names now, however still no effects... -
6. Re: how to set HtmlPanelMenuItem as selected
danielk Jan 7, 2009 7:23 AM (in response to janson12)Its working for me with following additional settings:
item.setMode("none");
panelMenu.setExpandMode("client"); panelMenu.setExpandSingle(true); // i think thats optional, because multi expanded groups are also possible
Perhaps you used other settings, which lead to a wrong behaviour? All i do to expand and select an item is, i call setSelectedChild() first with current node and than call item.getParent().setExpanded(true) until no parent from type UIPanelMenuGroup is available. Thats all and it's working for me, perhaps you missed something (parent form tag, outputPanel for ajax mode ...)? -
7. Re: how to set HtmlPanelMenuItem as selected
janson12 Jan 7, 2009 7:41 AM (in response to janson12)That was it!! It works with
panelGroup.setExpandMode("none")
andgroupItem.setMode("ajax");
Now nothing is sent when clicking on a panelGroup but that's acceptable for now. thanks a lot!! -
8. Re: how to set HtmlPanelMenuItem as selected
janson12 Jan 7, 2009 9:41 AM (in response to janson12)now that it is working another issue came up: whenever there's a non-ajaxian post request,e.g. by h:commandButton the menu kinda remembers the manually set selectedChild. i thought that selectedChild is set implicitly through EL when clicking on a menu item??