Category Archives: Wicket Framework

Hello World of Wicket Framwork:

Step1: Create a new Maven Wicket project having the following hierarchy.

image1

Step-2 Add Wicket and SLFJ dependencies in POM.xml file as follows.
4.0.0
com.mkyong.core
WicketExamples
war
1.0-SNAPSHOT
WicketExamples
http://maven.apache.org
org.apache.wicket
wicket
1.4.17


org.slf4j
slf4j-log4j12
1.5.6

WicketExamples
true
org.apache.maven.plugins
maven-compiler-plugin
1.6
true

Step -3 Create the deployement descriptor having the WicketFilter like as follows and specify your
WebApplication class as init param

Wicket Web Application
wicket.wicketTest
org.apache.wicket.protocol.http.WicketFilter

applicationClassName com.mkyong.MyApplication
wicket.wicketTest
/*

Step-4 Create MyApplication class which extends WebApplication and override getHomePage() method

package com.mkyong;
import org.apache.wicket.Page;
import org.apache.wicket.protocol.http.WebApplication;
import com.mkyong.hello.Hello;
public class MyApplication extends WebApplication {
@Override
public Class<? extends Page> getHomePage() {
return Hello.class; //return default page
}
}

Step-5 Create a new web page class which extends WebPage class

package com.mkyong.hello;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.model.Model;
public class Hello extends WebPage {
private static final long serialVersionUID = 1L;
public Hello(final PageParameters parameters) {
add(new Label("message", new Model("Hello World, Wicket")));
}}

Step -6 Create the html page parallel to the java class named hello.html

Wicket Hello World

message will be replace later

This wicket id should me mapped with label id.
Step-7 Run the application
image2

Wicket Introduction

Apache wicket is a light weight component-based web application framework for the java programming language conceptualy similar to JSF.

Why Wicket fremawork is used:
Three major advantages are as follows
1. Your html can be fully xhtml compliant – there is a VERY nice separation of presentation and logic in that the only thing your presentation/html layer needs to know about wicket are wicketid attributes in standard html tags. This is wonderful for the html/css/javascript client side guy on your team who does little to no actual java work. No other java based web framework can claim this, afaik.

2.No xml config for anything wicket specific – everything can be done in source and very little needs to be done to the standard web.xml for your .war

3.Component based development is pretty easy to grok – especially if you have a non web background (e.g. a swing programmer). it encourages reuse quite a bit more than mvc does, imo.