Advanced Features > Using DHTML-Based JSF Components to Build Web Applications > The JViews Framework Faces Component Set > Adding a Popup Menu

The popup menu component allows you to display a static or contextual popup menu when the application user right-clicks on the view.

As the popup menu is attached to a view, its JSP tag must be enclosed in the JSP tag for the view.

<jvf:view [...] >
  <jvf:contextualMenu [...]>
</jvf:view>

Code Sample 6.11 Contextual Popup Menu Tag in View Tag

The popup menu can be contextual or static.

Static Popup Menu

The menu displayed by the popup menu is static and fully on the client side.

To define a menu and menu items use the jv:menu, jv:menuItem, and jv:menuSeparator tags.

      <jvf:contextualMenu
        <jv:menu label="root">
          <jv:menuItem label="Zoom ..."
                       onclick="zoomButton.doClick()"
                       image="images/zoomrect.gif" />
          <jv:menuItem label="Pan ..."
                       onclick="panButton.doClick()"
                       image="images/pan.gif"/>
          <jv:menuSeparator/>
          <jv:menuItem label="Zoom In"
                       onclick="viewID.zoomIn()"
                       image="images/zoom.gif" />
          <jv:menuItem label="Zoom Out"
                       onclick="viewID.zoomOut()"
                       image="images/unzoom.gif"/>
          <jv:menuItem label="Zoom to Fit"
                       onclick="viewID.showAll()"
                       image="images/zoomfit.gif"/>
          <jv:menuSeparator/>
          <jv:menuItem label="Select"
                       actionListener="#{frameworkBean.action}"
                       image="images/arrow.gif"
                       invocationContext="IMAGE_SERVLET_CONTEXT" />
        </jv:menu>
      </jvf:contextualMenu>

Code Sample 6.12 Defining a Menu with Menu Items

Contextual Popup Menu

The popup menu is dynamically generated on the server side by a menu factory depending on:

To specify the factory use the factory or the factoryClass tag attribute of the contextual popup menu tag.

<jvf:contextualMenu factory="#{bean.factory}"/>
<jvf:contextualMenu factoryClass="com.xyz.demo.DemoFactory"/>

Code Sample 6.13 Specifying the Menu Factory

The factory must implement the IlvMenuFactory interface.