Hello World example is everybody's favorite example while starting any new technology. So in this Wicket tutorial we are going to develop first application in wicket which print "Hello World".
In the previous example you have learned how to create a project in the Wicket using the Net Beans IDE. In this "HelloWorld" example we need to create following three files:
One important thing to remember here is that you need to keep all these three files in a same folder. Here is the example code for HelloWorldApplication class.
HelloWorldApplication contains one constructor and a function which returns class and this is the class where we have added the "Hello World!" message. Full code of HelloWorld.java is as follows:
This HelloWorld class output would be rendered on HTML file. The "wicket:id" finds the component corresponding to component identifier and will show component as output on the browser. You will notice that message written in the span will be replaced with the label defined in the HelloWorld class.
<span wicket:id="message" id="message">Message goes here</span>
For HelloWorld example to run, we have to do corresponding entry of HelloWorldApplication class into the web.xml file. The entry that we need to do in the XML file is as follows:
To run this example run WicketExample project and type the following URL on the browser:
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial
Discuss: "Hello World" example in Wicket
Post your Comment