Using MAVEN to build wicket projects under NetBeans

Source: Internet
Author: User

Building the wicket project under NetBeans, the online approach is to use the NetBeans wicket plugin directly, although this is simple, but the dependent wicket version is older, the update is slow, and is easily incompatible with other third-party libraries. Building wicket projects with Maven can be a good integration of third-party dependent libraries, as well as the use of the latest wicket versions to mitigate certain security risks. The methods are described below.

First select New Project->maven->web application--Next

Next enter the project name and project location, select Next, select the server and Java EE version you use, click Finish, and create a MAVEN-based Web project. Next, add this web-dependent project.

When this web project is created, it generates pom.xml in the project file, opens it, finds the <dependencies> node, and adds wicket dependencies under that node:

<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-core</artifactId>
<version>6.22.0</version>
</dependency>
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-auth-roles</artifactId>
<version>6.22.0</version>
</dependency>
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-extensions</artifactId>
<version>6.22.0</version>
</dependency>
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-ioc</artifactId>
<version>6.22.0</version>
</dependency>

If you need to add jquery-ui, you can increase the following dependencies:

<dependency>
<groupId>com.googlecode.wicket-jquery-ui</groupId>
<artifactId>wicket-jquery-ui</artifactId>
<version>6.22.0</version> <!--or 1.5.11, 6.21.0--
</dependency>
<dependency>
<groupId>com.googlecode.wicket-jquery-ui</groupId>
<artifactId>wicket-jquery-ui-core</artifactId>
<version>6.22.0</version>
</dependency>
<dependency>
<groupId>com.googlecode.wicket-jquery-ui</groupId>
<artifactId>wicket-jquery-ui-calendar</artifactId>
<version>6.22.0</version>
</dependency>
<dependency>
<groupId>com.googlecode.wicket-jquery-ui</groupId>
<artifactId>wicket-kendo-ui</artifactId>
<version>6.22.0</version>
</dependency>

This time the dependencies are created and the latest version of the wicket library is imported as well. Next, set the code and where the resources are located. Locate the <build> node and add the resource node under the node, as follows:

<resources>
<resource>
<filtering>false</filtering>
<directory>src/main/java</directory>
<includes>
<include>**</include>
</includes>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>

Here the <directory> node specifies the location of the Java resource, which is the root directory where Pom.xml is located and the resource path below is Src/main/java.

You can then write wicket application code under the resource path, such as defining a application class that inherits from WebApplication and overloads some of the necessary methods. When the wicket code is finished, modify the Web page, delete the index.jsp, add a web-inf directory, add a. xml to the directory, and copy the following:

<?xml version= "1.0" encoding= "UTF-8"?>

<web-app xmlns= "Http://java.sun.com/xml/ns/javaee"
xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"
xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version= "3.0" >

<filter>
<filter-name>WicketApplication</filter-name>
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
<init-param>
<param-name>applicationClassName</param-name>
<param-value>com.example.src.Application</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>WicketApplication</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<session-config>
<session-timeout>
-
</session-timeout>
</session-config>
</web-app>
The <param-value> node corresponds to yourSrc/main/javaThe name and path of the next application class (here iscom/example/src)

So NetBeans under the wicket project was built.

Using MAVEN to build wicket projects under NetBeans

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.