You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

Introduction

This guide is intended to get you up and running & using Wicket within minutes.

It uses a Maven Archetype to create a Wicket QuickStart project, so requires that Maven 2 be installed & configured beforehand.

This project provides a starting point for your Wicket project. If you are looking for examples, please refer to the wicket-example projects instead!

Creating the project

To create your project, use the following command, modifying the bold elements as desired

mvn archetype:create -DarchetypeGroupId=org.apache.wicket
-DarchetypeArtifactId=wicket-archetype-quickstart
-DarchetypeVersion=1.3.0-beta4
-DgroupId=com.mycompany
-DartifactId=myproject

Results

This will produce the following project structure/files

    .\myproject
    |   pom.xml
    |
    \---src
        +---main
        |   +---java
        |   |   \---com
        |   |       \---mycompany
        |   |               HomePage.html
        |   |               HomePage.java
        |   |               WicketApplication.java
        |   |
        |   +---resources
        |   |       log4j.properties
        |   |
        |   \---webapp
        |       \---WEB-INF
        |               web.xml
        |
        \---test
            \---java
                \---com
                    \---mycompany
                            Start.java

Use

Change into the project directory, then create a WAR file via mvn package or build the project and run it under Jetty via mvn jetty:run.

Using the Jetty Plugin

This will compile the project then deploy it to an embeded instance of the Jetty servlet engine, which will be use on port 8080, by default. As a result, once running, your application will be available at http:localhost:8080/myproject.

See the Jetty plugin documentation for configuration options, etc.

Caveats

At present, running mvn package or mvn install will result in a NPE from the Surefire (testing) plugin as the generated pom.xml has no dependency on either JUnit or TestNG, which the plugin appears to expect if a src/test/java path is present. To avoid this issue, simply add the following to the <dependencies> section of the pom.xml.

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.2</version>
        <scope>test</scope>
    </dependency>

Using with a specific IDE

  • Eclipse
    • To create an Eclipse project, perform the "mvn eclipse:eclipse -DdownloadSources=true" command inside the project directory.
  • IDEA
    • To create an IDEA project perform the "mvn idea:idea" command inside the project directory, or if using IDEA 7 (available via the Early Access Program (EAP)), from within IDEA, just use "File/New Project/Import from external model/Maven", choose the project directory and select the generated pom.xml.
  • NetBeans
    • To create a NetBeans project perform the "mvn netbeans:netbeans" command inside the project directory, or if using NetBeans 6, just open the pom.xml directly.
  • No labels