Wicket In Action

Wicket will make you furious. In my case, I needed to simply import some CSS into a page. Chapter 9 is no help. The examples on the web are misleading.

Wicket automatically manages state at the component level, which means no more awkward HTTPSession objects. You don’t have to think about the fact that behind the scenes, state between requests is managed by Wicket. It just works. With JSPs, you have to make sure the context (which includes the page, request, and session attributes) is populated with the objects you need in your page. Wicket provides a programming model that shields you from the underlying HTTP technology so you can concentrate on solving business problems. In a Wicket application, each page consists of an HTML markup file and an associated Java class. Wicket forces you to use HTML templates that contain only static markup and placeholders where Wicket components are hooked in.

The book and a forum are available at http://www.manning.com/dashorst/
The source code for the examples is at http://code.google.com/p/wicketinaction/downloads/list
Chapter 15 has everything for setting up a Wicket project at http://www.manning.com/dashorst/Wicket_Bonus-chapter15.pdf

The Wicket site with the Javadocs is at http://wicket.apache.org/
A very large reference library wiki is at http://cwiki.apache.org/WICKET/reference-library.html
A component library is at http://wicketstuff.org/
Another Wicket site is at http://www.wicket-library.com/

The Readme file for these examples: README.txt
I tried to Upgrade to Wicket 1.4.3 in the pom.xml for the book… no luck.

Chapter Examples with Notes:

Source Files Home Page Examples List
cpt 1.3 cpt 3.1 cpt 3.2 cpt 3.3 cpt 4.2 cpt 5.2 cpt 5.3 cpt 5.4 cpt 5.5 cpt 5.6
cpt 6.1 cpt 6.2 cpt 6.3 cpt 6.4 cpt 6.5 cpt 6.6 cpt 6.7 cpt 7.1 cpt 7.2
cpt 8 cpt 9 cpt 10 cpt 11 cpt 12 cpt 13 cpt 14.2 cpt 14.3 cpt 14.4

At C:\wicket-in-action-0.9 type "mvn eclipse:eclipse" and a project will be built that you can open in Eclipse with all the jars and whatnot all configured.

Building the Examples with Maven:

See page 373 (page 11 of the PDF) of Chapter 15 on the web. (this chapter also covers web.xml and jetty setup).

When you use Apache Maven as your build tool, it will automatically download the dependencies for you and store them in a local repository. All your projects can then use this single downloaded JAR file. You won’t have to hunt down dependencies, download them manually and save them in a /lib folder when using Maven.

The repository is created here:
maven_repository.jpg

and the pom file controlling the build is here:
.. C:\wicket-in-action-0.9
pom.xml

I typed "mvn package" at C:\wicket-in-action-0.9 and got a build error:

[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

Missing:
----------
1) javax.transaction:jta:jar:1.0.1B

  Try downloading the file manually from:
      http://java.sun.com/products/jta

  Then, install it using the command:
      mvn install:install-file -DgroupId=javax.transaction -DartifactId=jta -Dve
rsion=1.0.1B -Dpackaging=jar -Dfile=/path/to/file

There was no jar file there, just jta-1_0_1B-classes.zip. I renamed it to jta-1_0_1B-classes.jar and tried the maven command to install the jar.
Then I followed the above instructions about installing it.

C:\wicket-in-action-0.9>mvn install:install-file -DgroupId=javax.transaction -Da
rtifactId=jta -Dversion=1.0.1B -Dpackaging=jar -Dfile=C:\jta-1_0_1B-classes.jar
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'install'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Wicket In Action
[INFO]    task-segment: [install:install-file] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [install:install-file]
[INFO] Installing C:\jta-1_0_1B-classes.jar to C:\Documents and Settings\Walt\.m
2\repository\javax\transaction\jta\1.0.1B\jta-1.0.1B.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Sat Oct 10 16:14:52 PDT 2009
[INFO] Final Memory: 3M/6M
[INFO] ------------------------------------------------------------------------
C:\wicket-in-action-0.9>

Then I tried "mvn package" again. It downloaded a mountain of stuff, ran 15 tests, then

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 40 seconds
[INFO] Finished at: Sat Oct 10 16:19:52 PDT 2009
[INFO] Final Memory: 15M/37M
[INFO] ------------------------------------------------------------------------
C:\wicket-in-action-0.9>

Then I typed "mvn jetty:run" at C:\wicket-in-action-0.9 and got…

********************************************************************
*** WARNING: Wicket is running in DEVELOPMENT mode.              ***
***                               ^^^^^^^^^^^                    ***
*** Do NOT deploy to your live server(s) without changing this.  ***
*** See Application#getConfigurationType() for more information. ***
********************************************************************
INFO  - OpenSessionInViewFilter    - Initializing filter 'opensessioninview'
INFO  - OpenSessionInViewFilter    - Filter 'opensessioninview' configured succe
ssfully
2009-10-10 16:30:16.465::INFO:  Started SelectChannelConnector@0.0.0.0:8080
[INFO] Started Jetty Server
[INFO] Starting scanner at interval of 60 seconds.

and running happily at localhost:8080 there was…

Home Page

Nice. Click the Examples link and …

Example List

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License