How to Use the breadCrumbs Component

18-30 Web User Interface Developers Guide for Oracle Application Development Framework The commandNavigationItem component housed within the nodeStamp facet of the navigationPane component provides the label text and action outcome for each navigation item. Each time the nodeStamp facet is stamped, the data for the current navigation item is copied into an EL-reachable property, the name of which is defined by the var attribute on the navigationPane component that houses the nodeStamp facet. The nodeStamp displays the data for each item by getting further properties from the EL-reachable property. Once the navigation menu has completed rendering, this property is removed or reverted back to its previous value. When users select a navigation item, the default JSF actionListener mechanism uses the action outcome string or destination URI to handle the page navigation. The XMLMenuModel class, in conjunction with nodeStamp facet also controls whether or not a navigation item is rendered as selected. As described earlier, the XMLMenuModel object is created from a tree model, which contains viewId attribute information for each node. The XMLMenuModel class has a method getFocusRowKey that determines which page has focus, and automatically renders a node as selected if the node is on the focus path. The getFocusRowKey method in its most simplistic fashion does the following: ■ Gets the current viewId attribute. ■ Compares the viewId attribute value with the IDs in internal maps used to resolve duplicate viewId values and in the viewIdFocusPathMap object that was built by traversing the tree when the menu model was created. ■ Returns the focus path to the node with the current viewId attribute or returns null if the current viewId attribute value cannot be found. The viewId attribute of a node is used to determine the focus rowKey object. Each item in the model is stamped based on the current rowKey object. As the user navigates and the current viewId attribute changes, the focus path of the model also changes and a new set of navigation items is accessed.

18.6.6 What You May Need to Know About Using Custom Attributes

Custom attributes that you have created can be displayed, but only for itemNode elements. To add an itemNode element to access the value of a custom attribute, you need to get the tree from the menu model by: ■ Calling the menu models getWrappedData method ■ Calling the getFocusRowKey method to get the current focus path ■ Using this focus path to traverse the tree and return a list of nodes in the focus path ■ Testing one or more of these nodes for custom attributes by calling the getCustomProperty API Example 18–15 shows an example of the required code. Example 18–15 Accessing Custom Attributes from the XMLMenuModel Returns the nodes corresponding to a focus path param tree param focusPath public List getNodesFromFocusPathTreeModel tree, ArrayList focusPath { Working with Navigation Components 18-31 if focusPath == null || focusPath.size == 0 return null; Clone the focusPath cause we remove elements ArrayList fp = ArrayList focusPath.clone; List of nodes to return List nodeList = new ArrayListObjectfp.size; Convert String rowkey to int and point to the node row corresponding to this index int targetNodeIdx = Integer.parseIntStringfp.get0; tree.setRowIndextargetNodeIdx; Get the node Object node = tree.getRowData put the Node in the List nodeList.addnode; Remove the 0th rowkey from the focus path leaving the remaining focus path fp.remove0; traverse into children if fp.size 0 tree.isContainer tree.isContainerEmpty { tree.enterContainer; get list of nodes in remaining focusPath List childList = getNodesFromFocusPathtree, fp; Add this list to the nodeList nodeList.addAllchildList; tree.exitContainer; } return nodeList; } public String getElementLabelXMLMenuModel model, Object myVal, String myProp { TreeModel tree = model.getWrappedData; Object node = findNodeByPropertyValuetree, myVal, myProp; FacesContext context = FacesContext.getCurrentInstance; PropertyResolver resolver = context.getApplication.getPropertyResolver; String label = String resolver.getValuenode, _LABEL_ATTR; return label; } public Object findNodeByPropertyValueTreeModel tree, Object myVal, String myProp 18-32 Web User Interface Developers Guide for Oracle Application Development Framework { FacesContext context = FacesContext.getCurrentInstance; PropertyResolver resolver = context.getApplication.getPropertyResolver; for int i = 0; i tree.getRowCount; i++ { tree.setRowIndexi; Get a node Object node = tree.getRowData; Get the value of the attribute of the node Obect propVal = resolver.getValuenode, myProp; if propVal == myVal { return node; } if tree.isContainer tree.isContainerEmpty { tree.enterContainer; node = findNodeByPropertyValuetree, myVal, myProp; if node = null return node; tree.exitContainer; }guap } return null; }

18.7 Creating a Simple Navigational Hierarchy

Figure 18–10 and Figure 18–11 show an example of what the user interface looks like when the navigationPane component and individual commandNavigationItem components are used to create a view for the page hierarchy shown in Figure 18–4 . Figure 18–10 Navigation Items Available from the View Employee Page When you create the hierarchy manually, first determine the focus path of each page that is, where exactly in the hierarchy the page resides in order to determine the exact number of navigationPanes and commandNavigationItem components needed for each page, as well as to determine whether or not each component should be configured as selected when the user visits the page. For example, in Figure 18–10 ,