-
1. Re: <rich:dropDownMenu>
ilya_shaikovsky Jan 15, 2010 10:52 AM (in response to dushmanlk)please show code snippets. -
2. Re: <rich:dropDownMenu>
dushmanlk Jan 15, 2010 12:16 PM (in response to ilya_shaikovsky)in the menu.xhtml
--------------------------------
<rich:toolBar>
<c:forEach items="#{menuItems.menuBar}" var="menu">
<rich:dropDownMenu binding="#{menu}">
</rich:dropDownMenu>
</c:forEach>
</rich:toolBar>
in the faces config
-------------------------------------
<managed-bean>
<managed-bean-name>menuItems</managed-bean-name>
<managed-bean-class>com.dushman.web.menu.backing.MenuItemBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
in the MenuItemBean.java
-----------------------------------------------
private List menuList;
public List getMenuBar() {
if(menuList == null){
menuList = getMenuComponent();
}
return menuList;
}
@SuppressWarnings
("unchecked")
public List<UIComponent> getMenuComponent() {
GrantedAuthority[] auth = SecurityContextHolder.getContext().getAuthentication().getAuthorities();
ArrayList<String> buf =
new ArrayList<String>();
for (int i = 0; i < auth.length; i++) {
buf.add(auth[i].getAuthority());
}
MenuItemDAO menuItem = (MenuItemDAO) ServiceFinder.findBean(
"menuItemDao");
List <MenuItem> list = menuItem.getMenuItemByRoles(buf);
List<UIComponent> menuList =
new ArrayList<UIComponent>();
FacesContext ctx = FacesContext.getCurrentInstance();
Application app = ctx.getApplication();
for (Object menu : list) {
HtmlDropDownMenu parent = (HtmlDropDownMenu) app.createComponent(HtmlDropDownMenu.
COMPONENT_TYPE);
parent.setValue(((MenuItem) menu).getItemName());
parent.setId(((MenuItem) menu).getUiId());
buildChildMenuItem(parent, ((MenuItem) menu).getChildMenus(), ctx);
menuList.add(parent);
}
return menuList;
}
private UIComponent buildChildMenuItem(UIComponent parent, Set<MenuItem> childs,
FacesContext context) {
for (Iterator<MenuItem> iterator = childs.iterator(); iterator.hasNext();) {
MenuItem menuItem = (MenuItem) iterator.next();
if (menuItem.getChildMenus().size() == 0) {
HtmlMenuItem item = (HtmlMenuItem) context.getApplication().createComponent(HtmlMenuItem.
COMPONENT_TYPE);
item.setValue(menuItem.getItemName());
item.setId(menuItem.getUiId());
item.setSubmitMode(
"ajax");
MethodExpression actionExpression = context.getApplication().getExpressionFactory()
.createMethodExpression(context.getELContext(),menuItem.getUri(), String.
class, new Class[]{});
item.setActionExpression(actionExpression);
// String onSelect = "open(this,'" +
// menuItem.getItemName().toString() + "')";
// item.setOnselect(onSelect);
parent.getChildren().add(item);
}
else
{
HtmlMenuGroup itemHasChilds = (HtmlMenuGroup) context.getApplication().createComponent(HtmlMenuGroup.
COMPONENT_TYPE);
itemHasChilds.setValue(menuItem.getItemName());
itemHasChilds.setId(menuItem.getUiId());
parent.getChildren().add(itemHasChilds);
buildChildMenuItem(itemHasChilds, menuItem.getChildMenus(),context);
}
}
return parent;
}
template.xhtml
---------------------------
<body>
<div id="page">
<div id="header"><ui:insert name="header">Header</ui:insert></div>
<div id="menu"><ui:include src="/WEB-INF/includes/menu.xhtml" /></div>
<div id="navigation"><ui:insert name="navigation">Navigation</ui:insert></div>
<div id="content"><ui:insert name="content">Content</ui:insert></div>
<div id="footer"><ui:include src="/WEB-INF/includes/footer.xhtml" /></div>
</div>
thank you showning interest in my question
dushmanlk
-
3. Re: <rich:dropDownMenu>
dushmanlk Jan 18, 2010 5:34 AM (in response to dushmanlk)But when i save the page to the file system and view it again. child menuescan be seen.
I'm using firefox browser
-
4. Re: <rich:dropDownMenu>
ilya_shaikovsky Jan 18, 2010 5:38 AM (in response to dushmanlk)component bindings should not be session scoped. -
5. Re: <rich:dropDownMenu>
dushmanlk Jan 18, 2010 6:13 AM (in response to ilya_shaikovsky)I changed it to request scope. still the problem exists.
Attached the screen shots before and after submit.
before submit, all child items are poulated.
after submit even i move cursor over the file menu child elements are not dispalyed.
but when i changed the submit mode to 'server' this works.
I used <ui:debug> and inspected view root. there is no diffence in both view roots
with refernce to menu components.
Any help very much appriciared.
Dushman.
-
after submit.JPG 65.0 KB
-
before submit.JPG 67.6 KB
-
-
6. Re: <rich:dropDownMenu>
nbelaevski Jan 19, 2010 6:34 PM (in response to dushmanlk)Hi,
Check if there are any errors in browser log & a4j:log component.
-
7. Re: <rich:dropDownMenu>
dushmanlk Jan 22, 2010 6:53 AM (in response to nbelaevski)Hi, Nick
I did check a4j:log
but its empty