-
1. Re: panelMenu questions
janson12 Mar 28, 2008 5:03 PM (in response to vace117)"vace117" wrote:
2) Is there a way to preserve the state of the menu when navigating from page to page?
I did that by property bindung, which means i create, design, save its state and obtain the menu from a backing bean:
if (panelMenu == null)
{
this.panelMenu = new HtmlPanelMenu();
/* --- First PanelMenuGroup --- */
HtmlPanelMenuGroup menuGroup_1 = new HtmlPanelMenuGroup();
menuGroup_1.setLabel("LABEL_1");
menuGroup_1.setName("MenuGroup_1");
menuGroup_1.setIconCollapsed("triangle");
menuGroup_1.setIconExpanded("triangleDown");
menuGroup_1.setId("menuGroup_1");
/* --- First PanelMenuItem --- */
HtmlPanelMenuItem menuItem_1_1 = new HtmlPanelMenuItem();
menuItem_1_1.setLabel(rb.getString("LABEL_1_1"));
menuItem_1_1.setName("menuItem_1_1");
menuItem_1_1.setStyleClass("navigation-menu-item"); menuItem_1_1.setActionExpression(createMethodExpression("someaction"));
...
public MethodExpression createMethodExpression (String target)
{
MethodExpression methodExpression = FacesContext.getCurrentInstance().getApplication().getExpressionFactory(). createMethodExpression(FacesContext.getCurrentInstance().getELContext(), target, null, new Class<?>[0]);
return methodExpression;
}
public void setPanelMenu(HtmlPanelMenu panelMenu)
{
this.panelMenu = panelMenu;
}
public HtmlPanelMenuItem getSelectedItem()
{
return selectedItem;
}
public void setSelectedItem(HtmlPanelMenuItem selectedItem)
{
this.selectedItem = selectedItem;
}
hope it helps a bit getting into all that weird stuff ;) -
2. Re: panelMenu questions
janson12 Mar 28, 2008 5:06 PM (in response to vace117)...bean must be session scoped of course!
-
3. Re: panelMenu questions
vace117 Mar 30, 2008 8:35 AM (in response to vace117)Thanks, Jason12. Binding the panelMenu component to a session scoped bean is a good idea and it looks like it works.
I looked a bit deeper into exactly what the action and actionListener attributes on panelMenuGroup do and it looks like there is a bug there (or I am missing something). UIPanelMenuGroup class implements ActionSource, which allows it to be a source of ActionEvents. So if I specify an action="" attribute for my panelMenuGroup the ActionEvent is queued as it should, except that UIInput from which UIPanelMenuGroup inherits doesn't know how to process ActionEvents! I am talking about this line in UIInput:public void broadcast(FacesEvent event) throws AbortProcessingException { if (!(event instanceof ValueChangeEvent)) { throw new IllegalArgumentException("FacesEvent of class " + event.getClass().getName() + " not supported by UIInput"); }
Since event is an ActionEvent, the above code blows up. How can this possibly work? It is, however, difficult to believe that no one ever tested the action attribute on panelMenuGroup :), so I am probably doing something wrong. Can anyone comment?
Thanks.
P.S. Just so its clear, here is exactly what I am doing:<rich:panelMenu mode="server" binding="#{menuBackingBean.htmlPanelMenu}"> <rich:panelMenuGroup expandMode="server" label='Home' action="#{menuBackingBean.homeMenuAction}" /> ...etc...
-
4. Re: panelMenu questions
vace117 Mar 31, 2008 4:50 PM (in response to vace117)Hmm, I guess this is more of a developer's forum question.... I think I will commit the sin of cross posting in this case :)
-
5. Re: panelMenu questions
janson12 Mar 31, 2008 7:02 PM (in response to vace117)Hi vace117, i would definitely help if i could! i'm myself struggling with an issue regarding the panelmenuitem and actionlistener (which doesn't seem to work and which apparently hasn't been tested by anybody before ;) good luck
-
6. Re: panelMenu questions
vace117 Mar 31, 2008 7:32 PM (in response to vace117)Incidentally, I was able to work around the problem by using
<rich:panelMenuItem styleClass="dr-pmenu-top-group" ...etc
and overriding:.rich-pmenu-top-item-label { font-weight: bold; font-family: Arial, Verdana, sans-serif; font-size: 11px; color: #FFF; }
in my css.
This effectively makes the item look like a group, so it works the way I want it to.
Still would be nice to get to the bottom of the action attribute not working... -
7. Re: panelMenu questions
ilya_shaikovsky Apr 1, 2008 8:12 AM (in response to vace117)checked at 3.2.0 GA. (demosite sample)
just chnaged one of the groups to<rich:panelMenuGroup label="Group 1" action="#{panelMenu.updateCurrent}" expandMode="ajax"> <f:param name="current" value="Just Group"/>
and it works for me. Action called, panel updated. -
8. Re: panelMenu questions
alexanderbelov Apr 1, 2008 8:38 AM (in response to vace117)Have anybody tried to use <rich:panelMenu> (RichFaces 3.2.0 GA) in Firefox 2.0.0.13 (Windows XP SP2)? No labels are displayed in menu. It works in IE, Safari.
-
9. Re: panelMenu questions
ilya_shaikovsky Apr 1, 2008 9:46 AM (in response to vace117)I've checked demosite on FF and IE. looks like I see the same for both browsers.
-
10. Re: panelMenu questions
rsinus Apr 1, 2008 9:49 AM (in response to vace117)This is a code to reproduce:
<rich:panelMenu mode="none" expandSingle="true" event="none" expandMode="none" id="menu" binding="#{menuBean.menuComponent}" style="margin-right:10px"> <rich:panelMenuGroup expanded="true" label="#{core.menuHeaderLabel}"> <c:forEach items="#{menuBean.menuItems}" var="menuItem"> <rich:panelMenuItem label="#{menuItem.label}" icon="triangle" name="#{menuItem.value}"> <a4j:support reRender="#{menuBean.navigateRerender}" limitToList="true" ajaxSingle="true" event="onclick" ignoreDupResponses="true" action="#{menuBean.selectMenuItem}"> <f:param name="menuItemValue" value="#{menuItem.value}"/> </a4j:support> </rich:panelMenuItem> </c:forEach> </rich:panelMenuGroup> </rich:panelMenu>
-
11. Re: panelMenu questions
alexanderbelov Apr 1, 2008 10:48 AM (in response to vace117)Fixed by custom setting:
.dr-pmenu-top-group-div
{
overflow:visible;
}
Thanks. -
12. Re: panelMenu questions
vace117 Apr 1, 2008 1:27 PM (in response to vace117)To follow up on the action attribute not working on panelMenuGroup...
Turns out that it works with JSF-RI and doesn't work with MyFaces due to lack of event type checking in UIInput.
Details are here: http://jboss.com/index.html?module=bb&op=viewtopic&t=132787