Wednesday, August 24, 2011

Things To Remember While Working With XML Menu Model.

Notes taken from DEV Guide:

1. Each node in the page hierarchy can be a parent and a child node at the same time, and each item node in the page hierarchy corresponds to a page.
2. A group node allows you to retain a hierarchy without needing to create pages for nodes that are simply aggregates for their children nodes. In other words, you dont need to create pages for Group Nodes.
3. Difference between Group Node & Shared Node:
Group Node: Groups child components; the groupNode itself does no navigation. Child nodes node can be itemNode or another groupNode.
Shared Node: References another XMLMenuModel instance. A sharedNode element is not a true node; it does not perform navigation nor does it render anything on its own.

In other words, a shared node can point to a menu model that begins with a group node.
Here is an example:

Root (Level 0) Menu code:
<?xml version="1.0" encoding="windows-1252" ?>
<menu xmlns="http://myfaces.apache.org/trinidad/menu">
  <itemNode id="itemNode_Home" label="Home" action="adfMenu_Home" focusViewId="/Home">
    <sharedNode ref="#{level1_menu}"/>
    <!--<itemNode id="itemNode_PartList" label="label_PartList" action="adfMenu_PartList" focusViewId="/PartList"/>-->
  </itemNode>
  <itemNode id="itemNode_Logout" label="Logout" action="adfMenu_Logout" focusViewId="/Logout"/>
  <itemNode id="itemNode_Help" label="Help" action="adfMenu_Help" focusViewId="/Help"/>
</menu>

Level 1 Menu code:

<?xml version="1.0" encoding="windows-1252" ?>
<menu xmlns="http://myfaces.apache.org/trinidad/menu">
  <itemNode id="itemNode_Main" label="Main" action="adfMenu_Main" focusViewId="/Main"/>
  <itemNode id="itemNode_ContactInformation" label="ContactInformation" action="adfMenu_ContactInformation"
            focusViewId="/ContactInformation"/>
  <sharedNode ref="#{level2_menu}"/>
</menu>

Level 2 Menu Code:

<?xml version="1.0" encoding="windows-1252" ?>
<menu xmlns="http://myfaces.apache.org/trinidad/menu">
  <groupNode id="itemNode_PartList" label="PartList" idref="itemNode_Inprocess">
    <itemNode id="itemNode_Complete" label="Complete" action="adfMenu_Complete" focusViewId="/Complete"/>
    <itemNode id="itemNode_ImportFile" label="ImportFile" action="adfMenu_ImportFile" focusViewId="/ImportFile"/>
    <itemNode id="itemNode_Inprocess" label="Inprocess" action="adfMenu_Inprocess" focusViewId="/Inprocess"/>
  </groupNode>
</menu>

Inaddition, there is not page for PartList node.

4. The value attribute of all navigation panes in a page template should reference only a root menu model and not any menu models referenced through shared nodes.  For example, if you use a shared node in your main XMLMenuModel element, JDeveloper would have created managed bean configurations for the shared node and the root XMLMenuModel bean that consumes the shared model. The shared model managed bean is automatically incorporated into the root menu model managed bean as the menu tree is parsed at startup.

1 comment:

  1. Great article! I have a question: how would you localize itemNode labels?

    ReplyDelete