In the previous section of Wicket tutorial you have studied about "printing Hello World", "creating Ajax Auto Completer" and some others very beautiful examples now in this section of Wicket tutorial we are going to describe you how you can create a website by creating templates of it.
In this section of Wicket tutorial we have created a website by using the template and it consists of four links as follows:
It consists one header and one footer which will remain same for all nothing will change but the content or page content will be changed according to links. For creating website we have three files as follows:
WebSite class file extends WebPage and it contains all the links and when these links are clicked then WebSite class calls its different page's class such as Home.class, Services.class, AboutUs.class, Contact.class.
Here is the full code of WebSite.java
package com.roseindia.wicket;
|
corresponding to WebSite.java its HTML file WebSite.html is as follows:
<html>
|
<wicket:child/> will remove this content with the markup of the derived component.
Here is the full code of WebsiteApplication.java
package com.roseindia.wicket;
|
Here is the full code of Home.java
package com.roseindia.wicket;
|
corresponding to Home.java its HTML file Home.html is as follows:
<html>
|
<wicket:extend> and </wicket:extend> extends the markup of the super class with this content.
Here is the full code of Services.java
package com.roseindia.wicket;
|
corresponding to Services.java its HTML file Services.html is as follows:
<html>
|
Here is the full code of AboutUs.java
package com.roseindia.wicket;
|
corresponding to AboutUs.java its HTML file AboutUs.html is as follows:
<html>
|
Here is the full code of Contact.java
package com.roseindia.wicket;
|
corresponding to Contact.java its HTML file Contact.html is as follows:
<html>
|
One most important thing to do with this example application is that we have to do the mapping of WebsiteApplication class mapping into the XML file web.xml.
| <filter> <filter-name>WebsiteApplication</filter-name> <filter-class> org.apache.wicket.protocol.http.WicketFilter </filter-class> <init-param> <param-name>applicationClassName</param-name> <param-value> com.roseindia.wicket.WebsiteApplication </param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>2</param-value> </init-param> </filter> <filter-mapping> <filter-name>WebsiteApplication</filter-name> <url-pattern>/wicket/website/*</url-pattern> </filter-mapping> |
To run this example start your Web Server and type the
following URL into web browser address bar:
http://localhost:8080/WicketExample/wicket/website
Home Page

Services Page

About Us Page

Contact Page

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Creating Website with the use of template in Wicket View All Comments
Post your Comment