Geertjan's Blog

  • April 10, 2007

Lessons Learned from the WebWork Framework (Part 3)

Geertjan Wielenga
Product Manager
I've added several new features to the WebWork module. One that is quite cool is a menu item that lets the application interact with the WebWork Config Browser. When you right-click on an "xwork.xml" file, a "Deploy to Config Browser" menu item is shown:

Maybe the menu item needs to be on project-level, instead of on the xwork.xml file. When you choose this menu item, the following code is performed:

protected void performAction(Node[] activatedNodes) {//First, standard code for finding the "nbproject" folder:
...//Next, we'll change the relative URL in "project.properties":
try {
FileObject projectprop = nbprojRoot.getFileObject(AntProjectHelper.PROJECT_PROPERTIES_PATH);
EditableProperties ep = loadProperties(projectprop);
ep.setProperty("client.urlPart", "config-browser/index.action"); // NOI18N
storeProperties(projectprop, ep);
} catch (IOException ex) {
}//Finally, we'll deploy the application by calling a target
//in "build-impl.xml":

FileObject buildImpl = nbprojRoot.getFileObject("nbproject/build-impl.xml");
ActionUtils.runTarget(buildImpl, new String[] {"run"}, new Properties());
} catch (IOException e) {
System.out.println("IO error: "+e);

So, what we're doing is changing the "client.urlPart" so that the relative URL is set to "config-browser/index.action", which is the URL relative to the context path for the Config Browser. And then the "run" target in build-impl.xml is called. However, this assumes that freemarker.jar is on the classpath and that this line is in the xwork.xml file:

<include file="config-browser.xml" />

However, it is fair to assume that both the above conditions are met, since the xwork.xml file that the wizard generates automatically contains the above line and the library that is selected in the wizard includes that JAR. However, some kind of check needs to be performed to verify that the JAR is available and that the above line is in the xwork.xml file.

Plus, I need to automatically change the "client.urlPart" back to what it was prior to the menu item being chosen, after the Config Browser is successfully deployed. But I don't know how to do that. Is there maybe a NetBeans API (or some standard JDK class or anything else) that lets one check whether a specific Ant target has been run or whether a certain URL is set in the browser?

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.