Skip to end of metadata
Go to start of metadata

Bookmarkable link

Table of contents

Setting Up Projects

We repeat what's been covered elsewhere here, but with a goal of having a common setup for the next section.

  1. Start by making sure Maven is installed and working via Setup Maven.
  2. Install IntelliJ via http://www.jetbrains.com/idea/download/
  3. In the terminal, cd to your working directory and run mvn archetype:generate. From the list, choose "wicket-archetype-quickstart". Maven will prompt for the version of Wicket you want to work with (use the latest of 1.4.x or 1.5.x as you desire).
  4. Next, Maven will prompt for groupId and archetypeId of the project being created, "test" for both is fine for now. Accept the provided defaults for the other prompts.
  5. Make sure everything builds via mvn install.

A project has been generated for you and you've tested it's without any compilation errors. So far we haven't done anything with IntelliJ, just gotten an sample project set up without any copying or pasting.

Setting Up IntelliJ IDEA

Setting up IntelliJ is so easy it almost doesn't deserve mention. Start IntelliJ, go to "File->Open Project" menu, and select the "test" project directory you generated in the previous steps. IntelliJ will automatically set up the source directories and classpaths. No complex IDE setup necessary!

J2EE Container Setup

Let's do some real work. First thing we have to do is set things up to run inside the IDE, then we can set a breakpoint that will be hit when a page is loaded. We'll do this with Tomcat to get started, but there are a lot of containers one can work from.

Ready? Let's go!

  1. Get your favorite version of Tomcat and unpack it somewhere you want it to stay.
  2. Inside IntelliJ, open select "Preferences" from the "IntelliJ IDEA" menu. Choose the "Application Servers" category in the left column (note it's under the "IDE Settings" category section if you already have a project open).
  3. At the top of the detail pane is a button labelled "Add". Click that, choose "Tomcat". Select the home directory of the Tomcat install you unpacked in step 1. The base directory will be filled in automatically. Click OK.
  4. With a container set up, we'll add a run configuration. Select "Run->Edit Configurations". Click the "+" button to add a configuration, in the popup menu, select "Tomcat Server->Local".
  5. The initial dialog that is opened will require an "artifact" to be selected. The easy way to do this is to find the "Fix" button at the bottom-right of the dialog. Click that, select "test:war exploded", and close the dialog.
  6. Select "Run->Debug". Your project should compile and open up a web browser window. Voila!

Debug Your Project

  1. Open a file in your new project. If you used the project we generated in the first section, you'll have a file called HomePage.java. The keyboard shortcut for opening a class is "Command-N" on Mac, "Alt-N" on other machines. Strike that key, start typing "HomePage". You'll see eligible classes start to come up. Select the class and open it up.
  2. Place a breakpoint by clicking in the left edge of the window. In our case, we want to set a breakpoint in the constructor for HomePage. If the container is running and the breakpoint is active, a subtle checkmark will be inside the red breakpoint marker.
  3. Reload your page. Note that IntelliJ has stopped execution and is waiting for your move!
Labels
  • No labels