You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by WarnerJan Veldhuis <wa...@qprcostcontrol.com> on 2009/10/02 13:17:52 UTC

Suggestion for Menu

Hello Bob et al. :)

FYI: I modified the Menu.java code in such a way that you can create 
menuitems based on ActionLinks. I saw the menu example, where the logout 
item was added manually, which does not integrate the item in the menu 
nicely.

Here's an example menu.xml which incorporates an ActionLink
<menu>
<menu label="Home">
<menu separator="true" roles="SU, DU, VU, WU"/>
<menu *label="logoffLink" **actionlink="true"* roles="SU, DU, VU, WU"/>
</menu>
</menu>

The label logoffLink corresponds to an ActionLink I added in my model in 
my TemplatePage class:

ActionLink logoffLink = new ActionLink("*logoffLink*", 
getMessage("logoffLink"), this, "onLogOff");
addControl(logoffLink);
getModel().put("menu", Menu.getRootMenu() );


The macro that renders the menu is modified slightly:
              #foreach ($subMenu in $topMenu.children)
                #if ($subMenu.isUserInRoles())
 ><li>
*#if ( $subMenu.isActionLink() )
                     #evaluate($subMenu)
                  #else
                     $subMenu
                  #end*
</li
                #end
              #end

With Menu#actionLink being true, the Menu will render the label as 
$label, making is suitable for the Velocity #evaluate( ) function.

If you want the code you can probably do it yourself now, but I'm happy 
to submit it somewhere.

Cheers,

WarnerJan