Apache Wicket : The greatest Java Web Framework Ever!
There has been a lot of confusion in Java Web world, as to what “will” work eventually with advent of so many Web Frameworks; each reinventing the wheel in some way or the other; trying to solve one problem ignoring others altogether.
I have accumulated fair amount of experience working with following frameworks ( UI / Web ):
- Struts 1.x ( Old, Stupid monolithic giant, which unfortunately many are still using).
- JSF ( Component based framework; customization of components is a nightmare … Configuration files crap still exists)
- Tapestry ( Great component based framework, best apart from Wicket )
- Spring MVC -> Customizable, perhaps too much flexibility;
- Struts 2.x -> Decent improvements over Struts 1.x but still the same with configuration files etc.
- GWT ( Google Web Toolkit )–> great, but requires a separate compiler;
- DWR ( Direct Web Remoting ) –> decent for AJAX. haven’t had a chance to explore it in entirety.
Out of all the above, I think Apache Wicket Framework stands out as the PROUD WINNER HANDS DOWN ( YeaH yEAH all you Tapestry people out there, try APACHE WICKET! ). Apache Wicket reminds me of Swing Model of programming; the best part is that while programming in Web Paradigm; i dont feel that i am in Web kind of programming mode. For example if i am coding things in struts or any other so called MVC framework, i would be doing JSP and writing configuration files and god knows what not.
Bottom line : WHY? WHY? WHY? WHY? what is the need for all of this ?
Flaws in frameworks which call themselves “MVC”
The truth is that i knew about this flaw for a long time ( Recently someone reminded me of this flaw over again, hence the rush to type in ) Basically, ( for those of you who are not familiar with MVC, refer to : MVC ) in almost all frameworks you’d find JSP which is a view, a controller servlet which handles and delegates to other classes some responsibility and controls the flow of application, the model which could be a Plain Old Java Object (POJO). Now the problem with JSP is that it simply (in almost all cases) is never a pure view, why? well because it has something called EL (expression language) which can provide for conditional constructs ( like for example
Here comes Apache Wicket!
To understand how Apache wicket solves above annoying issues, i think it’d be appropriate to go through with a simple application flow:
- you only needed 1 xml file (that is web.xml, d-oh!)
- You do what you “should” be doing as a java developer in the first place; write Java classes, each Java class (for example a Page type ) can have components, you add components the “same” way (almost) as you were used to adding in Swing framework back in old days (for me at least, haven’t worked in Swing for while). Your response or page navigation is based on classes and Classes Only! ( for example you have a button’s onSubmit( ) method in which you mention setResponsePage(NextClass.class, params); // where params is parameters you want to pass in ( And No they are not from request object! you would not need request object here … which is why i love this framework (i know … feels a little weird)).
- You html files DONOT contain logic of any sort, they are pure HTML files (well almost).
I have to try Flex and OpenLaslo yet, but Wicket is HOT!
Note : I haven’t been through the typical sequence of what happens when a request comes in, how Wicket handles it; I’ll cover those things in later posts …
For now try this site : Wicket Stuff
Regards
Vyas, Anirudh
“Wicket reminds me of Swing Model of programming”
Well, i did work on Swing. Perhaps some of that experience rubbed off.
Thanks for the kind words. Always nice to read a blog post like this.
Jon
BTW, I would not write an ordinary web application in anything but Wicket, but I think there is a place for Flex or GWT integration on sites built in Wicket. I look forward to GWT integration in the future.
Jon
Hey Jon,
Btw, we are fans of you, Igor and co.
I am involved with a project that is using Wicket officially and i was kind of “forced” to look into it ( I was going in … oh no not again mode, but was surprised) Yeah, i tried Flex recently; it has this incredibly slick feel to it. Slick as in the interface it generates is just unbelievably sweet looking. I am pretty sure that It will be something to watch out for in Next 3 years or so.
(My only problem is that I am not familiar with actionScript that much, granted that there are tools that can do that for you).
So yes, if there is a patch which bridges Wicket < ---> Flex; that will AWESOME!. Btw, I am not so excited about GWT …
Regards
Vyas, Anirudh
Sadly you completely missed out WebObjects, the mother of all Web Frameworks and still one of the best. WebObjects is not only the Framework that invented component based web development but also comes with one of the best and most mature persistence layers, “Enterprise Objects Framework” or short “EOF”. You find a short introduction here: http://en.wikipedia.org/wiki/WebObjects and more information (including JavaDoc) here: http://developer.apple.com/referencelibrary/DeveloperTools/idxWebObjects-date.html
regards,
Lars (Wicket and WebObjects user)
What I like about Wicket is that you can make self-documenting code that respects the DRY (Don’t Repeat Yourself) principle.
What I mean by “self-documenting” is that I can modularize a page into panels, give those panels names oriented towards the business logic, and describe my page in those simple, hierarichical terms — just as I can modularize a batch program as a hierarchy of well-named subroutines. This is much more readable than a HUGE tree of deeply nested tags.
If I am using similar panels in many places, I can write a single panel class to cover all the cases, with the differences in each usage configured via the constructor parameters of my panel subclass. Or, I can design my panel subclass with default or abstract methods to be overriden by (possibly anonymous) subclasses. Or I can combine both techniques. This gives me the same abstraction and re-use capabilities for the presentation logic that I already enjoy when coding the business logic.
If I want aspects of my application to have declarative configuration, I can simply include a configuration textfile in my application and write my code to read, parse, and use the information contained therein (without relying on the framework creator to guess the aspects I want to be declaratively configured).
Once you get the Wicket way of doing things, it’s as flexible and powerful as Java itself.
Anirudh: Great write up! I agree with your analysis and recently tried to capture the flaws in the MVC Action / JSP approach in a set of slides. It would be great if you can have a look and let me know if there are any points I have missed – based on your experience.
You can find the slides here:
http://ptrthomas.wordpress.com/2008/05/26/migrating-to-apache-wicket-presentation-slides/
You should do yourself a favour and check out Grails too.
I think that Wicket is nice, but if you part of a software team and you develop a Web application – choosing Wicket over Spring MVC will be very bad choice. The concept of mixing Java and Presentation – there is nothing good in it.
No matter what you will do with Wicket and no matter how many code Wicket will generate, you will finally stuck with some presentations problems.
But then you will realize, that much logic of the presentation is done in Java, with some hierarchy between classes and so on… so what kind of programmer you need for it?
A Java expert who is GUI HTML developer? The Java hierarchy between classes that will finally make an HTML page is also not a good idea, what for you need this in
presentation? Choose Velocity, Spring MVC, Tiles 2 and hire an HTML expert. That’s it.