-
1. Re: Keeping state of a panelMenu between pages
mmichalek Feb 8, 2008 2:45 PM (in response to jinpsu)Have you tried binding the panelMenu's selectedChild?
-
2. Re: Keeping state of a panelMenu between pages
jinpsu Feb 8, 2008 3:03 PM (in response to jinpsu)Can you keep track of expanding/collapsing of multiple groups with selectedChild? I thought no.
-
3. Re: Keeping state of a panelMenu between pages
mmichalek Feb 8, 2008 4:38 PM (in response to jinpsu)Yeah, that probably wouldn't work for multiple group states. I'm also interested to hear suggestions.
-
4. Re: Keeping state of a panelMenu between pages
jinpsu Feb 9, 2008 9:30 AM (in response to jinpsu)Anyone have an example on how to implement this?
Thanks. -
5. Re: Keeping state of a panelMenu between pages
moldovan Feb 11, 2008 4:05 AM (in response to jinpsu)I'm doing it this way:
On the JSF-Page:<rich:panelMenu binding="#{navigationMenu.panelMenu}" width="220" />
And the bean looks like:public class NavigationMenu { GuiUtil myGuiUtil = null; HtmlPanelMenu panelMenu = null; public HtmlPanelMenu getPanelMenu() { if(panelMenu == null) { panelMenu = new HtmlPanelMenu(); FacesContext facesContext = FacesContext.getCurrentInstance(); Application appl = facesContext.getApplication(); ELContext elContext = facesContext.getELContext(); ExpressionFactory exprFactory = appl.getExpressionFactory(); HtmlPanelMenuGroup menuGroup_AccountInfo = new HtmlPanelMenuGroup(); menuGroup_AccountInfo.setLabel(myGuiUtil.getMessageResource("menugroup_account")); menuGroup_AccountInfo.setName(myGuiUtil.getMessageResource("menugroup_account")); menuGroup_AccountInfo.setIconCollapsed("triangle"); menuGroup_AccountInfo.setIconExpanded("triangleDown"); HtmlPanelMenuItem menuItem_AccountInfo = new HtmlPanelMenuItem(); menuItem_AccountInfo.setLabel(myGuiUtil.getMessageResource("menugroup_account_products")); menuItem_AccountInfo.setName(myGuiUtil.getMessageResource("menugroup_account_products")); menuItem_AccountInfo.setActionExpression(exprFactory.createMethodExpression(elContext, "navigate_accountinfo", null, new Class[0])); menuGroup_AccountInfo.getChildren().add(menuItem_AccountInfo); panelMenu.getChildren().add(menuGroup_AccountInfo); ....... } return panelMenu; }
Hope, this helps! -
6. Re: Keeping state of a panelMenu between pages
jinpsu Feb 11, 2008 10:52 AM (in response to jinpsu)I'm still not sure I understand how you are keeping track of what panelMenuGroups are expanded/collapsed when navigating?
-
7. Re: Keeping state of a panelMenu between pages
moldovan Feb 11, 2008 12:03 PM (in response to jinpsu)Whats the problem?
For explanation:
-) you define your PanelMenu in a bean ( session scoped)
-) you can generate your panelmenu when the bean gets initialized (in the constructor). In my Example i do the generation of the panelmenu on the first call of the getter
-) define get-method and set-method - with these methods you save/restore your whole panelMenu (with all your expanded/collapsed panelMenuGroups)
-) implement panelMenu on JSF-Page via binding
There's no trick, thats all!
Try it out, and you will understand, how it's working! -
8. Re: Keeping state of a panelMenu between pages
jinpsu Feb 12, 2008 12:21 PM (in response to jinpsu)Works perfectly! Thanks!
-
9. Re: Keeping state of a panelMenu between pages
jinpsu Feb 12, 2008 3:58 PM (in response to jinpsu)Well, almost perfectly.
It seems as if state is only maintained during navigation. However, if I navigate to a page, expand (or collapse) a menu group, then refresh the page, it reverts back to the menu state from when I originally navigated to the page.
Is there any way to force the state to be saved when groups are expanded/collapsed? -
10. Re: Keeping state of a panelMenu between pages
moldovan Feb 15, 2008 6:07 AM (in response to jinpsu)The default-mode for expanding/collapsing the menuGroups is client. So its common that you will loose the state of your Menu, if you push the browser-refresh-button.
But, what you can do:
set the expandMode of all menuGroups to "Ajax - Expand Mode"!
You have to insert this code, when you generate your panelMenu from the bean:myMenuGroup.setExpandMode("ajax");
This should help! -
11. Re: Keeping state of a panelMenu between pages
jinpsu Feb 15, 2008 9:45 AM (in response to jinpsu)I read somewhere that it wasn't a good idea to mix ajax and navigation with the panelMenu. I get strange behavior if I set the mode of the panelMenu to anything but server. If I set the panelMenuGroups expandMode to ajax, I get ServletExceptions:
javax.servlet.ServletException: FacesEvent of class javax.faces.event.ActionEvent not supported by UIInput