History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: SM-49
Type: Improvement Improvement
Status: Open Open
Priority: Minor Minor
Assignee: Matt Raible
Reporter: Steve Smith
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Struts Menu

Allow users to use their own implementation of VelocityMenuDisplayer

Created: 28/Jun/06 12:58 PM   Updated: 09/Jan/07 11:30 AM
Component/s: Displayers
Affects Version/s: 2.4
Fix Version/s: 2.5

Environment: All


 Description  « Hide
Currently, Struts Menu is restricted to the supplied net.sf.navigator.displayer.VelocityMenuDisplayer class.

The menu displayer configuration suggests that you can switch in your own version of displayer:

<Displayers>
    <Displayer name="Velocity" type="net.sf.navigator.displayer.VelocityMenuDisplayer" />
</Displayers>

Having to give type the full class name suggests that you can override this, but, the net.sf.navigator.displayer.MenuRepository imports net.sf.navigator.displayer.VelocityMenuDisplayer directly and calls the static initialize() method:

public void addMenuDisplayerMapping(MenuDisplayerMapping displayerMapping) {

displayers.put(displayerMapping.getName(), displayerMapping);

log.debug("class name : " + VelocityMenuDisplayer.class.getName());

  if (displayerMapping.getType().equals(VelocityMenuDisplayer.class.getName())) {
if (servletContext == null) {
log.error("ServletContext not set - can't initialize Velocity");
} else {
     VelocityMenuDisplayer.initialize(servletContext);
   }
}
}

This means you cannot substitute your your own version of VelocityMenuDisplayer - for example, should you wish to remove the permissions checking code from:

protected void displayComponents(MenuComponent menu) throws JspException, IOException {
...
    // once you remove items, you can't put them back, so why not
    // just - do #if ($displayer.isAllowed($menu)) - in the Velocity macro?
    updateAllowedComponents(menu)
...
}

I suppose it is easy enough to modify the source code and re-build, but may be more flexible to allow users to switch in their own displayer implementation class.














 All   Comments   Change History   FishEye      Sort Order:
There are no comments yet on this issue.