Pages

Sunday, November 11, 2007

xml menu in JDeveloper 11g

A new feature in 11g is xml menu where you can define your own menu in xml and then adf can generate the menus with breadcrumb. You only have to make a menu xml and put in some navigation panes in the jsf template. You can have different types of menu on every level of the menu. On the left you see the main and level 1 menus are tabs and level 2 are lists. Under the list menu you see the breadcrumbs.
On the right there is a different menu type, level 1 and 2 menu are a bar menu.

It is very easy to make a xml menu is you already use adf taskflow. On the picture below you see several views. If you click on the diagram and use your right button you can create adf menu.
JDeveloper 11g generates a simple xml with 3 nodes on the same level
On the picture below you see the changes in the diagram. JDeveloper has created a wildcard control flow with control flow cases. Now it is possible to navigate between the pages. You can do it also without a wildcard control flow but then you have to specify for every view two control flow cases to the other views. JDeveloper generates also a bean configuration in adfc-config.xml so you can reference it in your jsf templates

Now we change the menu xml into a menu with different levels, group and a shared menu. A group item is not a jsf page it immediate redirects to a sub item when you click on it. A shared menu is a reference to an another menu xml which is loaded in this menu.



If you want to make a sharednode then you only have to copy the bean config and the menu xml .
The last step is to put in the navigation pane for the different menu levels in the jsf template of your pages. In the attribute hint you can define if you want tabs or bar etc. And we are ready to run it


Here is the workspace zip

18 comments:

  1. If you can also include some sample code for reference it would be indeed helpful.

    ReplyDelete
  2. Hi,

    Your blog is very helpful. It would be nice, you made accessible do to download JDeveloper workspaces with described examples.

    Kuba
    http://kuba.zilp.pl

    ReplyDelete
  3. Hi,

    Your blog is very helpful. It would be nice, you made accessible do to download JDeveloper workspaces with described examples.

    Kuba
    http://kuba.zilp.pl

    ReplyDelete
  4. hi All

    I updated the blogs with an workspace zip. happy coding

    ReplyDelete
  5. Thanks the source sample was great.

    ReplyDelete
  6. Hi,

    I found your blog while looking for how to create a dynamic menu in JDev 11g.

    I am quite new in this technology, so sorry if my question is stupid, but I am wondering if your example is to create menus dynamically or not. I'm not sure, so I tried to do as you explained but as I don't use adf taskflows, nothing is working.

    I need to create the bar menu on the .jspx page from a .xml file. Any help?

    Thanks beforehand, your blog is very useful, and sorry if this doesn't fit here.

    JDev user

    ReplyDelete
  7. Hi,

    I have a requirement where in I have to implement the dynamic navigation pane. It would be nice if you can suggest me how to achieve this?

    Thanks,
    Umesh

    ReplyDelete
  8. Hi,

    maybe this can help you.

    http://biemond.blogspot.com/2008/11/dynamic-menu-based-on-roles-database.html

    or this

    http://biemond.blogspot.com/2007/12/dynamic-jsf-menu.html

    thanks Edwin

    ReplyDelete
  9. Hi Edwin,
    First of all, I would like to thank you for all your articles. All of them are very clear and easy to understand.

    I have a question with the menus. We have a menu structure which has more than 3 levels. So the requirement is, levels 4 and above should be displayed as a af:tree. Can you tell me how this can be acheived.

    Thanks,
    Sirisha.

    ReplyDelete
  10. Hi,

    I don't think xml menu support 4 levels but then you should use a menubar.

    But If you want a tree menu then you can take a look at this blog entry http://biemond.blogspot.com/2008/11/dynamic-tree-menu-and-task-flow-regions.html

    thanks Edwin

    ReplyDelete
  11. Hi i follow the example on http://www.oracle.com/technology/products/jdev/11/cuecards111/adf_set_43/ccset43_ALL.html and when i run the page and click on menu Products or Shop i get the error:
    javax.faces.el.EvaluationException: Method not found: org.apache.myfaces.trinidadinternal.menu.ImmutableItemNode@8ce172.doAction(javax.faces.event.ActionEvent)

    It can't resolve the #{menuInfo.doAction} that i put on all af:commandNavigationItem

    do you have an idea?


    thanks.

    ReplyDelete
  12. Hi.

    Please check the faces-config.xml or all the Task Flows xml if this managed bean is defined somewhere and if the package name and class name is correct.

    if so check the bean if you can find the method

    ReplyDelete
  13. HI ,
    I have created a menu using the same approach but when i click the group node in the UI iam getting following exception please let me know how to resolve this:
    javax.servlet.ServletException: java.lang.StackOverflowError
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.adf.share.http.ServletADFFilter.doFilter(ServletADFFilter.java:65)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:85)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420)
    at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:54)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:247)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:157)
    at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.security.jps.wls.JpsWlsFilter$1.run(JpsWlsFilter.java:96)
    at java.security.AccessController.doPrivileged(Native Method)
    at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
    at oracle.security.jps.wls.util.JpsWlsUtil.runJaasMode(JpsWlsUtil.java:146)
    at oracle.security.jps.wls.JpsWlsFilter.doFilter(JpsWlsFilter.java:140)
    at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:70)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.dms.wls.DMSServletFilter.doFilter(DMSServletFilter.java:202)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3588)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2200)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2106)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1428)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused by: javax.faces.el.EvaluationException: java.lang.StackOverflowError
    at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:51)
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
    at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)
    at org.apache.myfaces.trinidad.component.UIXCollection.broadcast(UIXCollection.java:147)
    at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:87)
    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:87)
    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase

    ReplyDelete
  14. Hi,

    can you make a small testcase and send it to biemond at gmail dot com

    thanks

    ReplyDelete
  15. Hi Biemond,
    thanks for the reply,
    i found the mistake and corrected it
    its working fine now :)

    ReplyDelete
  16. Hi Edwin! How can I set rendered property of itemNode? For example I have page tamplate attribute with value, how to set rendered property to itemNode based on this pageTempalte Attribute?

    Best regards!

    ReplyDelete
  17. Hi Edwin,
    Could you please let me know how to add icons to a menu model? You have used the icon attribute of the af:commandNavigationItem.

    Regard!
    Sameera

    ReplyDelete
    Replies
    1. Hi,

      take a look at the adf faces demo to see what is possible with which component
      http://jdevadf.oracle.com/adf-richclient-demo/faces/index.jspx

      there is also commandNavigationItem in the navigation tree item

      Delete