This content has been marked as final.
Show 9 replies
-
1. Re: Create menuitem dynamically
nbelaevski Apr 4, 2009 2:11 PM (in response to abidz05)Hello,
What error?
How do you assign action?
Why not use c:forEach? -
2. Re: Create menuitem dynamically
abidz05 Apr 4, 2009 2:50 PM (in response to abidz05)"nbelaevski" wrote:
Hello,
What error?
How do you assign action?
Why not use c:forEach?k =new HtmlMenuItem(); Application app=FacesContext.getCurrentInstance().getApplication(); MethodBinding mb=app.createMethodBinding("listRoles", null); k.setActionListener(mb);
the error is below
Error Rendering View[/file.xhtml]
javax.faces.FacesException: javax.faces.FacesException: javax.faces.FacesException: Cant instantiate class: richMenu.. class richMenu : javax.faces.el.ReferenceSyntaxException: listRoles
at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:223)
at com.sun.facelets.tag.jsf.ComponentHandler.createComponent(ComponentHandler.java:224)
at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:139)
at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:314)
at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:169)
at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:314)
at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:169)
at com.sun.facelets.tag.jsf.core.ViewHandler.apply(ViewHandler.java:109)
at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)
at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:25)
at com.sun.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:95)
at com.sun.facelets.FaceletViewHandler.buildView(FaceletViewHandler.java:524)
at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:567)
at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:196)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:248)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.masjid.bader.persistence.session.HttpRequestFilter.doFilter(HttpRequestFilter.java:49)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:301)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.masjid.bader.security.SecurityFilter.doFilter(SecurityFilter.java:79)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.faces.FacesException: javax.faces.FacesException: Cant instantiate class: richMenu.. class richMenu : javax.faces.el.ReferenceSyntaxException: listRoles
at com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:503)
at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:82)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:61)
at org.apache.el.parser.AstValue.getValue(AstValue.java:107)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:212) -
3. Re: Create menuitem dynamically
abidz05 Apr 4, 2009 2:54 PM (in response to abidz05)"nbelaevski" wrote:
Hello,
Why not use c:forEach?
The menu is built in a backing bean depending on the privileges of the logged user -
4. Re: Create menuitem dynamically
nbelaevski Apr 6, 2009 4:41 AM (in response to abidz05)1. You should use setAction() and not setActionListener()
2. What is richMenu class and how does it correspond to "listRoles"? -
5. Re: Create menuitem dynamically
abidz05 Apr 6, 2009 7:59 AM (in response to abidz05)"nbelaevski" wrote:
1. You should use setAction() and not setActionListener()
2. What is richMenu class and how does it correspond to "listRoles"?
listRoles is just the outcome that will navigate me to the rolelist page.
richMenu class returns and instance of htmlToolBar to my page.
I worked with setAction and it works fine when I provide a bean method such as the following:MethodBinding mb=app.createMethodBinding("#{mybean.help}");
The error happens when I use the following:MethodBinding mb=app.createMethodBinding("listRoles", null);
OrMethodBinding mb=app.createMethodBinding("listRoles");
Now my question is there anyway I can set the action without providing a method binding?
Or is there anyway I can just navigate to rolelist page from the "ListRoles" outcome? -
6. Re: Create menuitem dynamically
nbelaevski Apr 6, 2009 9:09 AM (in response to abidz05)Try this:
commandLink.setActionExpression(facesContext.getApplication().getExpressionFactory().createMethodExpression(facesContext.getELContext(), "listRoles", String.class, new Class[0]));
-
7. Re: Create menuitem dynamically
abidz05 Apr 6, 2009 10:34 PM (in response to abidz05)"nbelaevski" wrote:
Try this:commandLink.setActionExpression(facesContext.getApplication().getExpressionFactory().createMethodExpression(facesContext.getELContext(), "listRoles", String.class, new Class[0]));
I could not implement this code with richfaces. I do not have the seactionexpression method -
8. Re: Create menuitem dynamically
ilya_shaikovsky Apr 7, 2009 5:14 AM (in response to abidz05)checked.
HtmlMenuItem item = new HtmlMenuItem(); item.setActionExpression(actionExpression);
should works. All such our components are the same as standard JSF h:command. -
9. Re: Create menuitem dynamically
nbelaevski Apr 7, 2009 5:32 AM (in response to abidz05)Are you using JSF 1.1?