Tomahawk navigationMenuItems tag

This tag is used to provide the menu items and sub items. This is the replacement of using many navigationMenuItem tags for items. The items for the menu are listed by the backing bean which is specified in the value attribute.

Tomahawk navigationMenuItems tag

Tomahawk navigationMenuItems tag

        

This tag is used to provide the menu items and sub items. This is the replacement of using many navigationMenuItem tags for items. The items for the menu are listed by the backing bean which is specified in the value attribute. 

Code Description : 

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<html>
<body>
<f:view>
<h:form> 
<t:jscookMenu id="menu" layout="hbr" theme="ThemeIE" >
<t:navigationMenuItems id="nmItems" value="#{ItemsBean.naviItems}" />
</t:jscookMenu>
</h:form>
</f:view>
</body>
</html>

 Backing bean :

package net.roseindia.web.ui;

import org.apache.myfaces.custom.navmenu.NavigationMenuItem;
import java.util.*;
public class ItemsBean {
public List getNaviItems() {
List menu = new ArrayList();

NavigationMenuItem home = new NavigationMenuItem("Home", null);
NavigationMenuItem contact = new NavigationMenuItem("Contact", null);
menu.add(home);
menu.add(contact); 

NavigationMenuItem item1 = new NavigationMenuItem("Examples", null);
home.add(item1);
item1.add(new NavigationMenuItem("Example1","welcome"));
item1.add(new NavigationMenuItem("Example2","welcome"));

NavigationMenuItem item2 = new NavigationMenuItem("Address","welcome");
NavigationMenuItem item3 = new NavigationMenuItem("Email","welcome");
contact.add(item2);
contact.add(item3);
return menu; 
} 
}

 Rendered Output :

Html Source Code :

<html>
<head>
<script type="text/javascript" src="/tomahawk_tags/faces/myFacesExtensionResource
/org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/11862282/navmenu.
jscookmenu.HtmlJSCookMenuRenderer/JSCookMenu.js"><!--

//--></script>
<script type="text/javascript" src="/tomahawk_tags/faces/myFacesExtensionResource/
org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/11862282/
navmenu.jscookmenu.HtmlJSCookMenuRenderer/MyFacesHack.js"><!--

//--></script>
<script type="text/javascript"><!--
var myThemeIEBase='/tomahawk_tags/faces/myFacesExtensionResource/org.apache.
myfaces.renderkit.html.util.MyFacesResourceLoader/11862282/navmenu.jscookmenu.
HtmlJSCookMenuRenderer/ThemeIE/';
//--></script>
<script type="text/javascript" src="/tomahawk_tags/faces/myFacesExtensionResource
/org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/11862282/navmenu.
jscookmenu.HtmlJSCookMenuRenderer/ThemeIE/theme.js"><!--

//--></script>
<link rel="stylesheet" href="/tomahawk_tags/faces/myFacesExtensionResource/
org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/11862282/navmenu.
jscookmenu.HtmlJSCookMenuRenderer/ThemeIE/theme.css" type="text/css" />
</head><body>

<form id="_idJsp0" name="_idJsp0" method="post" action="/tomahawk_tags/
pages/navigationMenuItems.jsf" enctype="application/x-www-form-urlencoded"> 



<script type="text/javascript"><!--
var idJsp0_menu_menu =
[[null, 'Home', null, '_idJsp0', null,[null, 'Examples', null, '_idJsp0', 
null,[null, 'Example1', 'idJsp0_menu_menu:A]welcome', '_idJsp0', null],
[null, 'Example2', 'idJsp0_menu_menu:A]welcome', '_idJsp0', null]]],
[null, 'Contact', null, '_idJsp0', null,[null, 'Address', 'idJsp0_menu_menu:A]
welcome', '_idJsp0', null],
[null, 'Email', 'idJsp0_menu_menu:A]welcome', '_idJsp0', null]]];
//--></script><div id="idJsp0_menu_menu"></div>

<script type="text/javascript"><!--
if(window.cmDraw!=undefined) { cmDraw ('idJsp0_menu_menu', 
idJsp0_menu_menu, 'hbr', cmThemeIE, 'ThemeIE');}
//--></script>
<input type="hidden" name="_idJsp0_SUBMIT" value="1" />
<input type="hidden" name="jscook_action" />
<script type="text/javascript"><!--

function clear__5FidJsp0()
{
clearFormHiddenParams__idJsp0('_idJsp0');
}

function clearFormHiddenParams__idJsp0(currFormName)
{
var f = document.forms['_idJsp0'];
f.elements['jscook_action'].value='';
f.target='';
}

clearFormHiddenParams__idJsp0();
//--></script><input type="hidden" name="javax.faces.ViewState" 
id="javax.faces.ViewState" value="rO0ABXVyABNbTGphdmEubGFuZy5PY
mplY3Q7kM5YnxBzKWwCAAB4cAAAAANzcgBHb3JnLmFwYWNoZS5teWZhY2VzLmFw
bnRGWRfYnEr2zwIABFsACV9jaGlsZHJlbnQASltMb3JnL2FwYWNoZS9teWZhY2Vz
L2FwcGxpY2F0aW9uL1RyZWVTdHJ1Y3R1cmVNYW5hZ2VyJFRyZWVTdHJ1Y3R" /></form>
<!-- MYFACES JAVASCRIPT -->
</body>
</html>

This tag contains attributes given below :

  • id : This is the value which is used to uniquely identify the component within the closest container like form or subview. The main thing to remember is that its value must be a static value.
  • binding : This attribute is used to specify the property of the backing bean with which this component instance is to be bound.
  • value : This is an EL expression that specifies the contents of the selection list.