X

Geertjan's Blog

  • September 1, 2005

Wicket Tools Support in NetBeans IDE

Geertjan Wielenga
Product Manager
A Wicket application is similar to a NetBeans web application. The differences are that (a) there's no JSP file, (b) HTML files are located in Java packages, (c) each HTML file is accompanied by a Java source file of the same name, (d) there's some Wicket-specific code in web.xml, and (e) Wicket uses Wicket-specific tags in HTML files to link the HTML files to the Java source files. So, the most important aspect of tools support for Wicket would be a project template located in the New Project wizard -- the project template should provide all of the aforementioned and the New Project wizard should enable you to specify one or two things (like project name, class name, HTML name, etc). Well, without typing a single line of code, this can be done. And here's how (use NetBeans IDE Dev, and a very recent version of it, because the following hasn't been available for very long):
  1. Use the New Project wizard to create a web application in NetBeans IDE. Then use the New File wizard to create all the files that you would like to include in the Wicket project template. Here's what it looked like for me:

    You could also include all the Wicket JAR files, but it's better to share the JAR files between applications. So, for the Wicket JAR files, you'd take the following steps separately.

  2. Use the New Project wizard to create a new plug-in module project. Then use the New File wizard to create a project template, selecting the Wicket application you defined in the previous step as the basis of the template. The New Project wizard even lets you specify where in the New Project wizard the Wicket project template should be located (click to enlarge):

    When you click Finish above, you get a whole bunch of files. The files define the wizard for creating the Wicket application. Here's what the Projects window looks like after you create the project template:

    There's also an XML Layer file that specifies where the project template will be found in the New Project wizard:

    Finally, the Wicket application that you defined in step 1 above, and which you selected in the first step of the Project Template wizard, is zipped up (WicketProjectTemplateProject.zip in the illustration above), and will be unzipped when you choose the Wicket application from the New Project wizard.

  3. Now you're done! You could finesse things a bit -- for example, you could add your own icon (which I did, in the illustration above), you could add additional panels to the wizard, you could change the description that appears in the New Project wizard, and you could reorganize the place of the template within the New Project wizard. There are many things you could do. But, basically, you're done. Right-click the project template module and choose Run Project. A new instance of the IDE opens. Click Ctrl-Shift-N and look in the category where you placed the Wicket project template (click to enlarge):

    Not bad, huh? Without typing a single line of code, you've created a project template that extends NetBeans IDE by enabling it to provide support for a technology that it doesn't support by default.

But this is only one aspect of tools support for Wicket. Other things to consider are -- file templates for web pages (each template would produce two files, an HTML file and a Java source file) and code completion for the Wicket tags in the HTML files. (Are there other things that Wicket users would like, Eelco and Martijn?) I'll look at these things in future blog entries.

Join the discussion

Comments ( 4 )
  • Gwyn Evans Thursday, September 1, 2005
    Regarding (d) and Wicket-specific code in web.xml...
    There's the standard <servlet> & <servlet-mapping> definitions that define the Wicket servlet and its init-param, but I'm not sure if that would count as Wicket-specific?

    Regarding (e), it uses Wicket-specific attributes to standard tags, rather than it's own tags, thus keeping the option of using standard HTML editors, etc.

    (Sorry, I know you know this, but I felt that other readers might get the wrong impression!)

  • Geertjan Thursday, September 1, 2005
    Thanks Gwyn. Both points taken. On (d) and (e) that's what I meant, sorry for not putting it clearly enough. In both cases, the Wicket project template would include code snippets -- the only slightly complicated thing from a NetBeans perspective would be code completion for the Wicket attributes in HTML. But it's also completely possible, just requires a little more work.
  • Chin Wednesday, April 5, 2006
    How to make the project name same as what we type when creating Wicket Application in New Project Wizard?
    For what I know it keep using WicketApplication in display name no matter what I type in project name during the wizard.
  • Geertjan Wednesday, April 5, 2006
    Hi Chin, that's an issue that I reported several months ago here. Feel free to add your own comments there.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.