Download NetBeans!

20050705 Tuesday July 05, 2005

Wicket Samples as NetBeans Projects

I've converted the Wicket Examples into NetBeans IDE projects. This means that you don't need to build the samples from scratch -- you can just download the ZIP file and open the samples as projects in NetBeans IDE 4.1. Once everything's set up and running smoothly, you can look at the source and learn how everything works.

Do the following to get going with Wicket in NetBeans IDE 4.1:

  1. Download the resources.

  2. Set up the samples.

    1. Open the samples. Start the NetBeans IDE and press Ctrl-Shift-O. The Open Project dialog box appears. Browse to where you unzipped the samples and select them all:

      Click Open Project Folder. The IDE opens all the projects. This dialog box appears, telling you that there are unresolved dependencies:

    2. Resolve the unresolved dependencies. Click Close in the dialog box above. Right-click "Upload", which is the last project in the list (or select any other project, other than DisplayTag), and choose Resolve Reference Problems. The following dialog box appears:

      Click Resolve. The Library Manager opens. Click New Library and create a library called "wicket", containing all the JARs found in the downloaded Wicket API's lib folder. (Optionally, if you don't want to use the servlet-2.3.jar, you can use the servletapi24.jar that is included in the NetBeans installation directory's enterprise1/modules/autoload folder.) Click OK and the IDE adds the wicket library to all the projects.

      But there are other unresolved references. Right-click "Upload" again, choose Resolve Reference Problems, click Resolve and select the "BasisForOtherSamples" project. This contains Java classes that are shared by the other samples. Repeat this process for all the other projects. (Since several samples share this project, you can modify these Java classes in one place -- in the separate project in which they are found.)

      Notice that DisplayTag has a few additional unresolved references. This is because DisplayTag is a pretty extensive sample, which requires several additional APIs. They are as follows (clicking on the following links brings you to where you can download the APIs) Commons Lang API, Commons Collections API, Wicket Extensions API.

  3. Run the samples. Once all the references have been resolved (or, at least, all the references for the samples in which you're interested -- you may want to leave DisplayTag for last), right-click a project and choose Run Project:

    Tomcat, which is bundled with NetBeans IDE, starts up automatically and your project is deployed. (Note that there are currently two projects that have problems with images, so that their images are not displayed correctly -- "Pub" and "Nested". I'll fix those soon.)

    Once the project is deployed succesfully (compare each deployed sample to their official Wicket version here if you're not sure), go back to the IDE and explore the sources, aided by the Wicket API Javadoc. (You can also join a Wicket Mailing List.)

Jul 05 2005, 05:34:29 AM PDT Permalink

Trackback URL: http://blogs.sun.com/geertjan/entry/wicket_samples_as_netbeans_projects
Comments:

I uploaded a 1.1 version of the NetBeans projectized Wicket samples -- I fixed some problems in "NavoMatic", "GuestBook", and "Pub". There's still a bug in "Nested". Everything else should work.

Posted by Geertjan on July 05, 2005 at 07:43 AM PDT #

Hi. This is very helpful! But BasisForOtherProjects has unresolved references. I have the 1.0.1 version of all the wicket stuff (api, extensions, examples). Errors are as follows

D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExampleApplication.java:25: package org.mortbay.jetty does not exist
import org.mortbay.jetty.Server;
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExampleApplication.java:27: package wicket.protocol.http does not exist
import wicket.protocol.http.WebApplication;
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExampleApplication.java:28: package wicket.util.crypt does not exist
import wicket.util.crypt.NoCrypt;
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExampleApplication.java:34: cannot find symbol
symbol: class WebApplication
public abstract class WicketExampleApplication extends WebApplication {
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExampleHeader.java:21: package wicket.markup.html.basic does not exist
import wicket.markup.html.basic.Label;
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExampleHeader.java:22: package wicket.markup.html.panel does not exist
import wicket.markup.html.panel.Panel;
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExampleHeader.java:29: cannot find symbol
symbol: class Panel
public final class WicketExampleHeader extends Panel
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExamplePage.java:21: package wicket.markup.html does not exist
import wicket.markup.html.WebPage;
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExamplePage.java:22: package wicket.model does not exist
import wicket.model.IModel;
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExamplePage.java:23: package wicket.util.string does not exist
import wicket.util.string.Strings;
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExamplePage.java:31: cannot find symbol
symbol: class WebPage
public class WicketExamplePage extends WebPage
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExamplePage.java:45: cannot find symbol
symbol  : class IModel
location: class wicket.examples.WicketExamplePage
        public WicketExamplePage(IModel model)
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExampleApplication.java:52: cannot find symbol
symbol  : class NoCrypt
location: class wicket.examples.WicketExampleApplication
        getSettings().setCryptClass(NoCrypt.class);
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExampleApplication.java:52: cannot find symbol
symbol  : method getSettings()
location: class wicket.examples.WicketExampleApplication
        getSettings().setCryptClass(NoCrypt.class);
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExampleApplication.java:60: cannot find symbol
symbol  : method getWicketServlet()
location: class wicket.examples.WicketExampleApplication
        String root = getWicketServlet().getServletContext().getRealPath("");
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExampleApplication.java:61: cannot find symbol
symbol  : method getSettings()
location: class wicket.examples.WicketExampleApplication
        getSettings().addResourceFolder(root);
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExampleApplication.java:62: cannot find symbol
symbol  : method getWicketServlet()
location: class wicket.examples.WicketExampleApplication
        if (this.getWicketServlet().getServletContext().getInitParameter("deployment") != null) {
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExampleApplication.java:64: cannot find symbol
symbol  : method getSettings()
location: class wicket.examples.WicketExampleApplication
            getSettings().configure("deployment");
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExampleApplication.java:67: cannot find symbol
symbol  : method getSettings()
location: class wicket.examples.WicketExampleApplication
            getSettings().configure("development");
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExampleApplication.java:77: cannot find symbol
symbol  : class Server
location: class wicket.examples.WicketExampleApplication
        Server jettyServer = null;
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExampleApplication.java:83: cannot find symbol
symbol  : class Server
location: class wicket.examples.WicketExampleApplication
            jettyServer = new Server(jettyConfig);
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExampleHeader.java:39: cannot find symbol
symbol  : class Label
location: class wicket.examples.WicketExampleHeader
        add(new Label("exampleTitle", exampleTitle));
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExamplePage.java:48: cannot find symbol
symbol  : method getClass()
location: class wicket.examples.WicketExamplePage
        final String packageName = getClass().getPackage().getName();
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExamplePage.java:49: cannot find symbol
symbol  : variable Strings
location: class wicket.examples.WicketExamplePage
        add(new WicketExampleHeader("mainNavigation", Strings.afterLast(packageName, '.')));
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExamplePage.java:49: cannot find symbol
symbol  : method add(wicket.examples.WicketExampleHeader)
location: class wicket.examples.WicketExamplePage
        add(new WicketExampleHeader("mainNavigation", Strings.afterLast(packageName, '.')));

Posted by Patrick Wright on August 12, 2005 at 06:53 AM PDT #

Hi Patrick, resolve those references by adding the Wicket libraries to the BasisForOtherProjects project. Do this by right-clicking this project's Libraries node in the Libraries window and then browsing to the JARs in the Wicket distribution. Hope this helps -- if not, please leave another message!

Posted by Geertjan on August 12, 2005 at 06:58 AM PDT #

Sorry, not in the Libraries window, but in the Projects window...

Posted by Geertjan on August 12, 2005 at 06:59 AM PDT #

OK, I needed to add Wicket-1.0.1.jar to the list--but looks like I'm missing Jetty. Any idea which version this is compiled with? Thanks Patrick

Posted by Patrick Wright on August 12, 2005 at 07:44 AM PDT #

Patrick, you shouldn't need Jetty. Tomcat's fine, it's bundled with the IDE -- the Wicket folks made their Wicket project without having NetBeans in mind, so that's why Jetty's there. Just right-click the project node, choose Properties, and in the Libraries panel remove the Jetty JAR from the list. Or, if you want to keep it, the JAR has got to be somewhere together with all the other Wicket libraries in the Wicket distribution. In fact, this adding of JARs from the Wicket distribution is described in my instructions in this blog entry -- look at step 2, right under the screenshot of the Resolve Reference Problems dialog box. Does this help?

Posted by Geertjan on August 12, 2005 at 07:49 AM PDT #

Geertjan--thanks for your help. Jetty is not in the list--just that Jetty classes are referenced in the BasisForOtherProjects--I imagine you have Jetty on your classpath somewhere?

D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExampleApplication.java:25: package org.mortbay.jetty does not exist
import org.mortbay.jetty.Server;
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExampleApplication.java:77: cannot find symbol
symbol  : class Server
location: class wicket.examples.WicketExampleApplication
        Server jettyServer = null;
D:\java\mywicket\wicket-netbeans-samples-1.1\BasisForOtherSamples\src\wicket\examples\WicketExampleApplication.java:83: cannot find symbol
symbol  : class Server
location: class wicket.examples.WicketExampleApplication
            jettyServer = new Server(jettyConfig);

Posted by Patrick Wright on August 12, 2005 at 08:02 AM PDT #

Patrick, the Wicket distribution includes <tt>org.mortbay.jetty-4.2.22</tt> (or some other version). This is what you need to include.

Posted by Geertjan on August 12, 2005 at 08:05 AM PDT #

Geertjan--I don't find any files with *jetty* in the Wicket-1.0.1 distribution--I have the binary distribution. Maybe this was taken out between 1.0 and 1.0.1? I will download Jetty separately. Thanks for your help.

Posted by Patrick Wright on August 12, 2005 at 08:11 AM PDT #

Yes, I see. I wrote this blog entry for Wicket 1.0, but they seem to have taken out Jetty for some reason. You could search for Jetty in the BasisForOtherProjects project, and just remove whatever dependency in the project needs it, because it really isn't necessary from a NetBeans perspective -- since there's already Tomcat available. Thanks for the heads up -- I'll add a new blog entry for Wicket 1.0.1 as soon as possible, in the next few days.

Posted by Geertjan on August 12, 2005 at 08:20 AM PDT #

Sorry, "BasisForOtherProjects" above should say "BasisForOtherSamples"...

Posted by Geertjan on August 12, 2005 at 08:21 AM PDT #

Just to follow up--wicket-<version>.jar needs to be added to the wicket library in netbeans--it's in the parent directory above lib. In my case, I needed to download and add the jetty libraries as well--I downloaded version 4.2 and added all its jars as a library. GuestBook works! Thanks. Patrick

Posted by Patrick Wright on August 12, 2005 at 08:25 AM PDT #

Excellent, thanks for the info. Glad to see it's worked for you. Plus, that you're able to use a NetBeans IDE Dev build with this (because 4.2 isn't released yet, so you're using a post-4.1 Dev build). If you come across any problems whatsoever with Wicket in NetBeans, please leave a message here -- it would be very useful for me when writing the 1.0.1 update for 4.2 (or even just for 4.1). Note that elsewhere in this blog (click here) I show how you can add the Wicket samples to the IDE's New Project wizard -- which has a lot of advantages, especially if you're someone like me -- who messes things up and then quickly needs an unmessed-up version to be available, especially during the learning phase when things tend to mess up really quickly!

Posted by Geertjan on August 12, 2005 at 08:30 AM PDT #

Oh, when you said 4.2, maybe you meant Jetty, and not NetBeans. Oh well. :-)

Posted by Geertjan on August 12, 2005 at 08:35 AM PDT #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed