Dojo Menu and Menu Item

Complete Java Server Faces (JSF) Tutorial - JSF Tutorials. JSF Tutorials at Rose India covers everything you need to know about JSF, This JSF Tutorial contains readable and interesting content organized in proper and sequential manner. Each concept has been explained by simple examples so that you can understand easily and implement immediately into your java web application. It provides coverage of key JSF concepts such as User Interface(UI) components, Renderers, Backing beans, Validators, Converters, Navigation, Event handling, Expession language, Messages etc...

Dojo Menu and Menu Item


In this section, you will learn about the menu and how to create it in dojo.

Menu : This is the widget models a context menu, otherwise known as a right-click or popup menu, and it appears in a ComboButton and DropDownButton widgets. If you click on the right button of the mouse then popup menu is appeared on the screen.

MenuItem widgets are an actual items in the menu. The PopupMenuItem is a MenuItem, but it displays a submenu or other widget to the right . A PopupMenuItems always have two child nodes: a tag with the displayed label (Using SPAN tag), and a widget to be popped up, typically a dijit.Menu widget.



Here is code of program:

<title>Menu Demo</title>
  <style type="text/css">
  @import "../resources/dojo.css";
  @import "../dijit/themes/tundra/tundra.css";
  <script type="text/javascript" src="dojo.xd.js" 
   djConfig="parseOnLoad: true"></script>

  <script type="text/javascript">
 function call_function(choice) {
  alert(choice+" was clicked.");
  function save_function() {
  alert("Save Button");
  function save_as_function(choice) {
 alert("Save As Button");
<body class="tundra">
<b>Creating DropDownButtons</b><br>
<div dojoType="dijit.form.ComboButton" onclick="save_function">
  <div dojoType="dijit.Menu" id="saveMenu" 
   toggle="fade" style="display: none;">
  <div dojoType="dijit.MenuItem"
 iconClass="dijitEditorIcon dijitEditorIconSave" 
  <div dojoType="dijit.MenuItem" onclick="save_as_function">
  Save As
<div dojoType="dijit.form.DropDownButton">
  <div dojoType="dijit.Menu" id="Edit">
  <div dojoType="dijit.MenuItem" label="Copy"
  <div dojoType="dijit.MenuItem" label="Cut" 
  <div dojoType="dijit.MenuItem" label="Paste"

  .myIcon {
 background-position: -16px 0px;
 width: 16px;
 height: 16px;
  <div dojoType="dijit.Menu" id="submenu1"
  <div dojoType="dijit.MenuItem" iconClass="myIcon"
 onClick="alert('Hello world');">Enabled Item</div>
  <div dojoType="dijit.PopupMenuItem" id="submenu2">
  <div dojoType="dijit.Menu">
  <div dojoType="dijit.MenuItem"
   onClick="alert('Submenu 1!')">
Submenu Item One</div>

  <div dojoType="dijit.MenuItem"
   onClick="alert('Submenu 2!')">
Submenu Item Two</div>


Here is code of program: