views:

58

answers:

2

How could I encapsulate the authentication logic, the URL and the label of a Menu item when I make use of e.g. a Dojo MenuItem widget?

What I currently have is this:

<auth:isRole  role="admin">
  <div dojoType="widget.Menu.MenuItem">
    <a href="<html:rewrite page="... complicated url ..."/>">
      <bean:message key="label.goes.here"/>
    </a>
  </div>
</auth:isRole>

And what I would like to achieve would be something like:

<util:menuitem role="admin" link="...complicated url..." label="label.goes.here" />

Is this possible to implement with a custom tag? Would there be other options to use Ajax or JS helpers?

+1  A: 

There's a project called Struts Menu that is a combination of a taglib, a config file, and Velocity templates to encapsulate menu display logic and security. I don't think there's an existing Velocity template for Dojo menus, but it shouldn't be difficult to write one.

Jason Gritman
+1  A: 

It most certainly is possible with a custom tag but including other tags in a custom tag can be ornery. Facelets is a good alternative to JSP that has actually replaced it in the J2EE spec for J2EE6. It allows you to create custom tags via other components. Check out this as it is a good tutorial.

Drew