X

Geertjan's Blog

  • April 14, 2007

Menu Items for Registering/Deregistering WebWork Actions

Geertjan Wielenga
Product Manager
For the NBWebWorkSupport project, I need highly versatile menu items, for registering/deregistering Actions in the xwork.xml configuration file. They need to meet the following requirements:

  • First, they need to appear on Java nodes, but only for projects that support WebWork. This requirement, and its solution, was discussed in Show/Hide Menu Items Based on Deployment Descriptor Content.

  • Second, the menu item for deregistering a Java class's Actions needs to be enabled only when there are Actions to be deregistered. When there are no Actions registered for the current class, the menu item for deregistering them needs to be disabled.

For the second requirement, to understand it better, look at the screenshot below. In the xwork.xml file, there are no Actions for the selected class in the xwork.xml file. In other words, the class "Login" is selected, the right-click contextual menu appears, and shows the "Deregister from WebWork Actions" menu item is disabled. Why? Well, look in the xwork.xml file below... it shows there is one Action and the class attribute's value is "com.acme.action.HelloWorld":

Hence, there are no Actions registered for the Login class and, for that reason, the menu item is disabled. As soon as an Action is registered for the class, which is done using this (currently very rudimentary) dialog box...

...the menu item becomes enabled. Everything is done, on this point, based on the Action's "class" attribute in the Action's Action element. That required heavy use of regular expressions. When the menu item for deregistration of Actions is chosen (after I registered three Actions for the Login class), this dialog box is shown, just as a confirmation of the event that is about to happen:

Again, a lot of regular expressions were needed to get the Action names into the drop-down above. Right now, the code works exactly as it should. As soon as there are no more related Actions in the xwork.xml file, the deregistration menu item automatically disables. As soon as a Java class is registered, just once, the deregistration menu item enables automatically. Pretty cool. The code is in the project's CVS directory, if you're interested.

In other news. My colleague Troy completed the world's best, most detailed, and funniest MySQL tutorial for web applications in NetBeans IDE. Read Creating a Simple Web Application in NetBeans Using MySQL and laugh while you learn!

Join the discussion

Comments ( 4 )
  • hantsy Saturday, April 14, 2007
    Hello, I have tried this plugin.
    There is my idea.
    1.move the file "xwork.xml" from "Source Packages"v
    to "Configuration Files"
    2.why not provide a more friendly and powerful xwork.xml editor(like the "web.xml" editor, and I think the "sun-web.xml" editor is better), thus the "Menu Items for Registering/Deregistering WebWork Actions " function is not needed.
  • Allen Sunday, April 15, 2007

    Geertjan,

    Any chance that all this WebWork support for Netbeans is going to be extended into Struts2 support any time soon? I am very glad to see WebWork support, but now that WebWork is being merged into Struts2 it seems like that would be of even more benefit. In fact, the WebWork team just announced they believe they've made their final release.

  • Geertjan Monday, April 16, 2007
    Hi hantsy, I'm going to do both of those things, thanks for pointing them out and watch this space for further development.

    Hi Allen, go to https://nbstruts2support.dev.java.net/ for details on our Struts 2 project. The useful parts of my NBWebWorkSupport project will be moved the the NBStruts2Support project, sometime after JavaOne. Meantime, I will continue working on the NBWebWorkSupport project.

  • goodscape Tuesday, May 1, 2007
    Thanks
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.