Context-sensitive menu using WebWork

Looking to build a generic context-sensitive menu using WebWork. Came up with the following requirements:

  • All items described below are menu elements.
  • A menu element has a name attribute.
  • A menu element has a parent menu element.
  • If a menu element does not have a parent, it is the root menu.
  • A menu element is only aware of its structural representation, i.e.: it’s a model.
  • A menu may be composed of other menus.
  • There is only one root menu.
  • The root menu has a default menu set.
  • The default menu is shown if the current use case does not provide a menu.
  • There is a mechanism to change the current menu based on the current use case.
  • A menu may have child menu items.
  • A menu item has an action attribute. The view will rely on this to react to a menu item being selected or clicked. This action may be a URL or script call.

The visual representation of the menu elements above could be as simple (html) or complex (Ajax/DHTML) as the end user wants. As a default, you could use a simple html output. The output would basically output the root menu’s immediate children. While displaying a menu item, the cell/div would be clickable. Its onclick would either send the user to a given URL, or execute a given script call.

In terms of setting the menu based on the current context, an interceptor requesting the desired root menu seems enough. For example, FooAction would implement MenuProvider. A MenuProvider would return its desired root menu. If FooAction wanted to modify the existing root menu, rather than completely replacing it, it would implement MenuAware. The same aforementioned interceptor would set the root menu on MenuAware classes.

Constructive suggestions appreciated.

This entry was posted in Technical stuff. Bookmark the permalink.

One Response to Context-sensitive menu using WebWork

  1. Konstantin Pribluda says:

    I’m not sure this has to be integrated with WW using
    interceptorsm interfaces or whatever.

    I use simple XML based system in pico/nano/webwork environment ant it is build out of:
    – menu structure itself ( read with betwixt, pretty simple beans, hierarchical )
    – menu state ( state of current menu shall be kept somewhere for entire request because of inclides / sitemesh
    – activator components ( could be action,
    but I prefer startable components placed in specific containers )
    – couple of visitors ( helps by rendering / path buildup )

    I put it online under:
    http://www.sourceforge.net/projects/jtec
    ( not much there yet, just sources )

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.