| Author |
Message |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 16/11/2006 08:59:33
|
mdbbe
Joined: 16/11/2006 00:00:00
Messages: 16
Offline
|
I want my menu to be dynamic (loaded from the database).
How can I do that?
Thank you,
mdbbe
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 16/11/2006 10:54:11
|
philip.breau

Joined: 08/05/2006 00:00:00
Messages: 2691
Offline
|
Hi mdbbe,
You can do this with the <ice:menuItems> components.
...in your JSF page...
Code:
<ice:menuBar orientation="horizontal">
<ice:menuItems value="#{bean.model}"/>
</ice:menuBar>
...in your bean you dynamically create the menu...
Code:
private List model; //list for the dynamic menus w/ getter & setter
private void createMenuItems() {
model = new ArrayList();
//Help Menu
MenuItem helpMenu = createMenuItem("Help","help",null,null, null);
helpMenu.getChildren().add( createMenuItem("About My Application","about","#{bean.actionListenerMethod}","#{bean.actionMethod}", "./myIcon.gif"));
model.add(helpMenu);
}
private MenuItem createMenuItem(String label, String id,
String actionListener, String action, String icon) {
MenuItem menuItem = new MenuItem();
menuItem.setValue(label);
if( id != null )
menuItem.setId(id);
if( actionListener != null ){
menuItem.setActionListener(createActionListenerMethodBinding(actionListener));
}
if( action != null ){
menuItem.setAction( createActionMethodBinding(action) );
}
if( icon != null )
menuItem.setIcon(icon);
return menuItem;
}
private MethodBinding createActionListenerMethodBinding(String actionListenerString) {
Class args[] = { ActionEvent.class };
MethodBinding methodBinding = null;
methodBinding = FacesContext.getCurrentInstance().getApplication()
.createMethodBinding(actionListenerString, args);
return methodBinding ;
}
private MethodBinding createActionMethodBinding(String action) {
Class args[] = { };
MethodBinding methodBinding = null;
methodBinding = FacesContext.getCurrentInstance().getApplication()
.createMethodBinding(action, args);
return methodBinding;
}
Thanks,
Philip
|
. |
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 20/11/2006 15:20:40
|
mdbbe
Joined: 16/11/2006 00:00:00
Messages: 16
Offline
|
I strong typed the List and made a few changes. But it basically did the trick for me. Thank you.
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 23/07/2007 07:29:46
|
bayer-dba
Joined: 03/07/2007 00:00:00
Messages: 99
Offline
|
As far as I can see MethodBinding is deprecated and replaced by the Unified EL method "ExpresionFactory.createMethodExpression()".
Therefore setAction() & setActionListener() should be able to accept a MethodExpression, too?!
Is this a part of http://jira.icefaces.org/browse/ICE-606 or should someone create a separate issue?
Regards.
|
Dennis Bayer | JBoss 4.2.2GA - Sun RI - IceFaces 1.8.2 w/ Facelets |
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 23/07/2007 11:01:28
|
philip.breau

Joined: 08/05/2006 00:00:00
Messages: 2691
Offline
|
Hi,
Thanks for noting this. I've created a jira for this issue: http://jira.icefaces.org/browse/ICE-1907, which 606 now depends on.
Philip
|
. |
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 26/07/2007 07:58:27
|
sruthi
Joined: 26/07/2007 00:00:00
Messages: 1
Offline
|
I used the example given in the samples to crate dynamic menu ,I get the following error-
Jul 26, 2007 6:34:14 PM com.icesoft.faces.webapp.parser.Parser parse
SEVERE: Failed to execute JSP lifecycle.
javax.servlet.jsp.JspException: Bean: IceFaces.BackBean.menuBean, property: model
at com.icesoft.faces.component.menubar.MenuBarTag.doEndTag(MenuBarTag.java:240)
at com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:203)
at com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:186)
at com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:186)
at com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:186)
at com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:186)
at com.icesoft.faces.webapp.parser.Parser.parse(Parser.java:134)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:557)
at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:154)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
at com.icesoft.faces.webapp.http.core.PageServer$1.respond(PageServer.java:26)
at com.icesoft.faces.webapp.http.servlet.ServletRequestResponse.respondWith(ServletRequestResponse.java:125)
at com.icesoft.faces.webapp.http.core.PageServer.service(PageServer.java:31)
at com.icesoft.faces.webapp.http.servlet.BasicAdaptingServlet.service(BasicAdaptingServlet.java:16)
at com.icesoft.faces.webapp.http.servlet.SingleViewServlet.service(SingleViewServlet.java:45)
at com.icesoft.faces.webapp.http.servlet.PathDispatcher$Matcher.serviceOnMatch(PathDispatcher.java:52)
at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:29)
at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:97)
at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:35)
at com.icesoft.faces.webapp.http.servlet.PathDispatcher$Matcher.serviceOnMatch(PathDispatcher.java:52)
at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:29)
at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
at java.lang.Thread.run(Thread.java:595)
I am able to create <ice:menuitem> but not able to use <ice:menuitems>. Please help
|
|
|
 |
|
|