What is an Apache Wicket?
Apache Wicket, commonly referred to as Wicket, is a lightweight component-based web application framework for the Java programming language conceptually similar to JavaServer Faces and Tapestry.
Applications are written in pure java with XHTML, thus making learning this concept much easier without the need to depend on XML and JSTL. Wickets “Component” based approach makes it more reusable, extending different sections of a web application. Any programmer who is good in Java coding can find Wicket as one of the finest web application frameworks. It can be easily developed and deployed using eclipse framework. Testing is more user-friendly using JUnit and its one of the few frameworks that provide testing APIs.
APACHE WICKET ARCHITECTURE
Why use Wicket?
When one starts using Apache wickets, there is a clean separation of concerns ie, web designer need not care about the code and the programmer without the need to confuse with designing.
It makes a developer more Java-ised , as its more emphasized on Object- Oriented programming. The big advantage of wicket is focus on Java and clear cut separation of business logic from the view of the application.
Whenever a developer uses Java as a platform for development, he may not be implementing the actual object oriented approach, but in this case they learn to use the power of object-orientation in application development. Well when you try to learn Wicket , its actually Java or more specifically Object oriented programming you get skilled in. Object-orientation makes it easy to develop and cut clear business aspects.
We discuss below some of the reasons why Wicket is choose in application development industry
1. Focus on Components and re usability:
Components are piece of reusable software replaceable by same component meeting same interface. In wicket components can be text fields, buttons, panels, images etc. Components in here are extendable. For example if you have a panel (Say search box) to be used in many pages, it can be extended by encapsulating it into a reusable component.
Making Wicket components reusable is very easy. Suppose we require a Link to homepage to be used at various pages of an application. Then the reusable components for this link can be created as
public class addLink extends Link { private addLink(String id) { super(id); } public void onClick() { setResponse(new Homepage()); } }
This component can be reused anywhere by instantiating and adding it as and when required.
So next time when we want this link to be used,
add(new addLink("homepage"));
Instead of
add(new Link("homepage") { public void onClick() { setResponse(new Homepage()); } });
And its redirected to Home page, we need not specify each time the location to be redirected, thus saving time and memory especially for larger application.
2. Pure Java and Real Object Oriented Programming
This is what a growing developer likes about Wicket. You learn more Java-ism while trying to develop an application using Apache Wickets. A lot of java developers does not use the power of object orientation, but wickets change that mindset. So if you are strong in Java fundamentals, then learning wickets is not at all a steep curve for you. Many Java frameworks move developers toward non-OO, non- Java programming, but wicket does the reverse.
Java Programmers on the way from procedural programming like JSP, Struts, Stripes might find it difficult initially to develop a wicket application by instantiating every component with Models, not like in those where they just hammer out some code into the html. Here we keep on programming Object – oriented without derailing whether its for View or Controller. So the challenge is not to learn Wickets but more object orientation. It makes wickets much easier to develop and cut clear business aspects of the application.
3. Clear separation of Java and Html
Wicket imposes the strategy that no more java code in html (that was the case in JSP). In wicket we have pages composed of panels/components, each one with two files, a java and an html file. We can match java components to wickets using wicket id.
Say we have a textfield in a our java class, fullName
add(new TextField("fullName"));
to add that in html, we use id syntax of wicket
<input wicket:id="fullName"/>
No special tags other than Html is used and No xml files used for configuration either.
Clear separation of logic and no custom tags lead to an .html file fully standardised, and the work of the front view can now be assigned to a Designer and developer need not care about the design issues. This can make development process more accurate and reliable. The HTML can be fully xhtml compliant. If you have separate team working on the presentation, their work can be completely isolated from coding people and result used as-is.
4. No more JSP!
Programming is made more efficient and easy by developing your application in pure java than in JSP and limited syntax of JSTL. Unlike others there is nothing new to learn for Wicket, just Java and pure Html. JSP’s had the problem of being getting un-maintainable. We can refractor more easily with Wickets and problems can be caught at compile time, the same which is not possible with JSP. And your java code is clear as crystal with no more jsp tags embed in it. The only downside is you may have to recompile a little more than as in JSP. The markups can be changed on the fly and refresh in debug mode. Reusability in JSP is a custom tag or include file.
5. Ajax
Well, we can name this feature as the best among the all Wicket advantages.Before discussing on Ajax Wicket a little on javascript.
Learning javascript is not an hard task, but what is hard is learning IE8 javascript, chrome javascript, firefox javascript, etc. There is hardly some differences, but it causes huge hangups and performance issues. For most developers the Ajax brought on the web is not the topic of interest because of javascript. As most of them find it too complex or maybe they just hate “javascript”. Wicket take away you from this issue by allowing you to embed the ajax functionality into your web application without a single line of code in javascript.
For example autocomplete instance which uses ajax to pop up list can be used like this:
AutocompleteTextField testTextField = new AutoCompleteTextField(“myField”,new Model(“”)); Protected Iterated getChoices(String input) { return dataService.getPossibleChoice(input); }
The wicket community has built Ajax mechanisms in such a way that it works in all browsers and users need not care about Javascript. With a few line of code, developers can implement javascript events to a server side callback. Wickets with their component model handles Ajax very well.
6. Good integration with Spring
Integrating your wicket application with dependency injection frameworks is worth mentioning. We can easily inject the spring beans inside our pages, panels, components , model ,etc by just using
@SpringBean annotation
Suppose we have a Spring bean DataService with a method to retrieve all Bank Transactions,
then we can inject that spring bean using
@SpringBean DataService service; setResponsePage(new ListBankTransaction(service.findAllBankTransactions()));
7.Highly Suitable for
* Highly Interactive applications
* Online Registration applications
* Applications with lot of forms/UI controls
* Applications requiring seamless Ajax behaviour
In short, Application development using Wicket are just amazing and you would love to continue developing in the same framework once used.
Wicket has its own big community which reacts to bugs and questions quickly.
As far as limitations for wickets are concerned, limitations are basically opinions based on attitude towards each framework. Wicket do has its own limitations in the application development industry.
Many of the blogs places before you ask the question, how many Java Web Frameworks can you list? well there are many web frameworks but not many pure java frameworks. Now you can list Wicket one among them for sure. As its pure Java.