Geertjan's Blog

  • October 18, 2005

Overcoming NetBeans Limitations Via Wizards

Geertjan Wielenga
Product Manager
Currently you can't create an HTML file in a Java package in a web application. (See Issue 64869. Workaround: Create it somewhere else and then move it into the Java package of your choice.) This is not a problem for anyone, except those using NetBeans IDE to develop Wicket applications. (Wicket expects the HTML file to be in the same location and bearing the same name as the Java source file that defines the components rendered by the HTML file.) To circumvent this problem (and to, basically, add various goodies for Wicket developers, as well as, even more importantly, to educate myself on how the NetBeans Wizard APIs work so that I can write a Wizard API tutorial), I've been working on a Wicket Web Page file wizard. The current version of this file-level wizard creates an HTML file and a Java source file with the same name in the same package (which complies with Wicket conventions as well as resolving the issue of HTML files not being creatable in Java packages in web applications, plus it simplifies life since, per Wicket web page you want to create, you always need to create a Java source file and an HTML file because together they define a Wicket web page, so creating them simultaneously saves time and makes sense).

So, this is where you choose the new file-level wizard (the description in the panel explains what you'll end up getting if you use this wizard—an HTML file and a Java source file).

And here's the first panel (and, thanks to the bottom panel—which seems to be a recent-ish feature that many NetBeans IDE wizards have, so that the user doesn't have to click 'Next' if there are only two panels—this is also the last panel in the wizard):

The lower part of the panel currently does nothing. Ultimately, a checked component will result in Java code being added to the Java source file and HTML tags (for rendering the component) in the HTML file.

In addition to the HTML file and Java source file (with some default code), currently the Wicket servlet is declared in web.xml when the above wizard is complete. Of course, I should move that part of the code to the project-level template, because the servlet should be declared only once—when the project is created (not every time a web page is created). But, this has been the most interesting part so far—learning how to use the J2EE DD API (especially see this usage page for some interesting examples) has been tricky (thanks for the help, Milan!) but, at the same time, quite a lot of fun. I'll add what I learnt about this API to the Wicket Project Template Module Tutorial soon...

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.