Geertjan's Blog

  • April 11, 2007

Show/Hide Menu Items Based on Deployment Descriptor Content

Geertjan Wielenga
Product Manager
Something I'm pretty proud of... two new menu items, which only appear on a Java node if the web.xml file registers certain WebWork artifacts, such as its filter:

Really cool bit of code. When the menu item is selected, an Action element is added to the xwork.xml file. The unregistering isn't complete yet, I'll have to look for a regular expression and then remove it. But being able to show/hide a menu item on a Java node depending on the presence/absence of something in web.xml is pretty useful. It makes complete sense to assume that the WebWork artifacts are registered in the web.xml, because that's what happens when you complete the New Project wizard for WebWork, i.e., by the end of the wizard you'll have selected 'WebWork', and then the wizard adds the WebWork filter to the web.xml file. Struts and JSF have a similar approach in NetBeans IDE, for detecting whether or not they are supported by the current application, in the Project Properties dialog box, to show/hide the possibility of adding them, which implies that something shouldn't be there, otherwise you shouldn't be able to add it. Fun, fun.

A different (better?) approach might be to check the classpath for the presence of the WebWork JAR file. (Or to write a .webwork file to the home directory, or to the NetBeans user directory, when the wizard finishes and "WebWork" was selected and to then check for the presence of that file when determining whether to show/hide the menu items.)

Join the discussion

Comments ( 1 )
  • Karl Wednesday, April 18, 2007
    Whoa, that -is- cool. Not only is it cool, but it's a good UI design.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.