Geertjan's Blog

  • May 1, 2008

Wicket 1.3.3 Support for NetBeans IDE 6.1

Geertjan Wielenga
Product Manager
Today we uploaded the latest NBMs of our Wicket support into the Plugin Portal:


There are several changes, some mentioned recently in this blog. Basically, the names of the generated templates are friendlier, the JARs are Wicket 1.3.3 instead of 1.3.0, some useless options have been removed from the Frameworks panel, the Wicket Stylesheet support is part of the generated code, the Wicket filter is used in web.xml instead of the Wicket servlet, a header panel is always created... so mostly quite simple enhancements that, I believe, will make the user experience a lot better. Click the above link, then the Download button on the Plugin Portal page, unzip the ZIP that you then get and install the three NBMs. There is no need to download Wicket JARs from the Wicket site, because one of the three NBMs provides these and registers them in the IDE when you install the NBM.

I've installed them into 6.1, though they should probably also work in 6.0. Here's a quick scenario that should show you most of the Wicket support provided by this plugin, together with some nice Wicket/Ajax integration:

  1. Create a new web application and choose Wicket in the Frameworks panel:

  2. When you click Finish you have a nice simple source structure to begin your adventures with Wicket:

    (From a NetBeans API point of view, the coolest thing about the above screenshot is that you see exactly that when you complete the wizard, i.e., the package opens automatically and the HomePage.java is also opened automatically, so that you can begin coding there right away. It's a small thing, but pretty cool.)

  3. Right-click on the package (not on the project node, else you'll come across a known bug in this plugin) and choose New | Other and then choose the Panel template from the New File dialog:

  4. Name your panel:

  5. Click Finish and you have the skeleton of a new panel, i.e., both the Java side and the HTML side:

  6. Add a text field to the HTML side of the new panel, with a Wicket ID that will connect the HTML to the Java side of the panel:

  7. On the Java side of the Country Panel, use Wicket's AutoCompleteTextField class, as follows, making sure to pass the 'countries' ID, which connects the Java side with the HTML side defined in the previous step:

    final AutoCompleteTextField field = new AutoCompleteTextField("countries", new Model("")) {
    protected Iterator getChoices(String input) {

    if (Strings.isEmpty(input)) {
    return Collections.EMPTY_LIST.iterator();
    List choices = new ArrayList(10);
    Locale[] locales = Locale.getAvailableLocales();
    for (int i = 0; i < locales.length; i++) {
    final Locale locale = locales[i];
    final String country = locale.getDisplayCountry();
    if (country.toUpperCase().startsWith(input.toUpperCase())) {
    if (choices.size() == 10) {
    return choices.iterator();}

    Above, the bits in bold is Wicket, the rest is just standard JDK code for getting the country names for the available locales. Here we're just building up a collection that will be displayed in the auto complete text field that we are creating here. The collection could contain anything at all, but Wicket provides the class that will make the text field behave in a way that we've come to expect from Ajax.

  8. Now add the field to the panel, on the Java side, by adding the one line below that is in bold, in the constructor:

    CountryPanel(String id) {
  9. Hurray. You've just defined your first reusable panel. Now let's actually make use of it. In the HomePage.html, add a new tag below the existing tag, i.e., add the tag that is in bold below:

    <link wicket:id='stylesheet'/>
    <span wicket:id='mainNavigation'/><span wicket:id='countryPanel'/>

    The Wicket ID you specify here could be anything, so long as it is matched by the Wicket ID we add to the Java side, in the next step.

  10. In the HomePage.java, instantiate the Country Panel, by simply adding the line in bold (all the rest was generated by the Frameworks panel in the Web Application wizard):

    package com.myapp.wicket;           
    import org.apache.wicket.model.CompoundPropertyModel;
    public class HomePage extends BasePage {
    public HomePage() {
    setModel(new CompoundPropertyModel(this));add(new CountryPanel("countryPanel"));

    In the same way that you've instantiated the Country Panel above, you could do so anywhere else, such as in the generated Header Panel. You just need to make sure that the Wicket ID is the same on both sides, i.e., in the HTML file and in the Java file.

  11. Hurray, you're done. Deploy the application to the server of your choice. Notice that you now have an auto complete text field in your browser:

What have you learned? Firstly, you've learned that NetBeans IDE has cool support for Wicket (and you haven't seen everything yet, for example, when you refactor a Java class, the related HTML side will be refactored at the same time and you can cause a hyperlink to be created on the Wicket ID on the HTML side, which will let you open the Java side from inside the HTML page, plus the Navigator shows the Wicket tags in the page, plus there's Wicket samples in the New Project wizard). Secondly, you've learned about one of Wicket's Ajax classes (go here for more). Thirdly... how much JavaScript have you used in order to create a very typical Ajax component? Well... ummm... none. So, you can use Ajax without leaving the comfortable world of Java. Fourthly, in the debug mode, which is Wicket's default mode, there's a cool debug console right inside the HTML page, which provides a lot of useful information about the current session. Fifthly (but something you can't see here), if the browser doesn't support JavaScript, Wicket provides fallback behavior to handle this for you. Finally, isn't it cool that you can wrap your Ajax behavior in your own Wicket components and then reuse them, so easily?

Join the discussion

Comments ( 15 )
  • Kevin Slater Thursday, May 1, 2008


  • dabar Friday, May 2, 2008

    Wonderful and Thank You!

  • hantsy Sunday, May 4, 2008

    I found a problem.

    In a none-wicket project , the "Wicket Tags" is still in dropdown menu in Navigitor window.

    I think this feature must be aware of the wicket project , not for all projects.

  • Jonathan Locke Monday, May 5, 2008

    Hey, this is really coming along... nice work!

  • MohamedIthiris Thursday, June 5, 2008

    Hello Sir i am new comer for wicket.

    i am download the wicket plugin from the plugins.netbeans.org.

    and install it.

    i will try to run your program. but cant run.

    there has been error from the class.

    please send me the steps and coding

  • Geertjan Thursday, June 5, 2008

    Mohamed Ithris, that's not very much information, I can't help you at all. Please describe your problem more precisely [ALL the steps you took and ALL the results, i.e., EVERYTHING] and send them to me at geertjan DOT wielenga AT sun DOT com.

  • Selva Tuesday, July 8, 2008

    Gud Eve sir. thanks a lot for helping me to run a first wicket application. morning u had sent me a tutorial i just followed and i am very very happy that it run successfully. Now i tried this country panel example this also working. thanks a lot. also my thanks to Mr. Varun sir.

    Now i want to create a form and two textfield which should get input at runtime. help me plz.thank u.

  • Geertjan Tuesday, July 8, 2008

    For questions about Wicket, you should contact the Wicket community, they have their own website, mailing lists, tutorials, etc. http://wicket.apache.org/

  • Maxat Friday, September 26, 2008

    I can not find wicket plugins for netbeans6.1..

    and the following page is not availlable: http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=3586

    Please advise where I can download it.

  • Geertjan Friday, September 26, 2008

    The Plugin Portal seems to be down. Just please be patient and try that link again later.

  • Ken Friday, December 5, 2008

    Hi - Thanks for your work on the wicket plugin for netbeans! I was considering customizing the work you have done and extending it specifically for where I work. I can not seem to find the source. I checked https://nbwicketsupport.dev.java.net but that seems a bit dated. I may have overlooked a link to get the source on the plug-in page... Please help :-)

    Thank you,


  • Geertjan Wielenga Friday, December 5, 2008

    Not dated at all. Just check it out and adapt it as you like.

  • Chip McCormick Friday, January 23, 2009

    It looks like the plugin link has changed to the following:


  • Geertjan Friday, January 23, 2009

    It's now available in the Plugin Manager, inside the IDE, in 6.5. No need to download any plugins separately. Just start up NetBeans and go to the Plugin Manager.

  • Shalini Friday, February 5, 2010


    How we can use autosuggest with a model having id and name.


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