Showing posts with label web framework. Show all posts
Showing posts with label web framework. Show all posts

Wednesday, February 21, 2007

Wicked wicket framework
---------------------------
I had earlier blogged about my foray into web 2.o and how I ended up trying wicket. I still am quite impressed with Wicket though I no longer work with it. Wicket interested me because it had a TreeTable component which I wanted to adapt to display XML. The exisiting TreeTable in Wicket displayed static, hierarchical data that could display only 5 columns. This was because the Wicket used a model bean which is a plain old java bean that looked like this:

public class ModelBean {

public ModelBean() {
}

public String getColumn_1_Value() {
}

public String getColumn_2_Value() {
}


:
:
:
}

What I envisaged would solve the problem was:

public class MyModelBean {

public MyModelBean() {...


public String getColumnValue(int columnNumber) {
if(columnNumber == 0)
return name;
else if(columnNumber == 1)
return size;
else if(columnNumber == 2)
return type;
else if(columnNumber == 3)
return lastModified;
}


This way the treetable would be able to display any kind of hierarchical data. However, in the end it proved to be easier said than done. Wicket uses PropertyResolver to resolve a compound expression of the form

userObject.value

which then got evaluated to

getUserObject().getValue()
}


using reflection. i.e 2 calls were being made on the PropertyResolver. The first one would ofcource return the userObject associated with the ModelBean and the getValue would then be called on the userObject. My new version would then pass the columnNumber as the argument to getValue. Further, key classes and methods inside wiket were marked private which hindered direct subclassing and workarounds had to be devised. Further there were so many execution paths since Wicket supports indexing of arrays, hashmaps besides javabean types that finding the places that needed changing was difficult to say the least. But as they say, Alls well that ends well and the code is now in the Apache incubator as Wicket has formally been inducted into Apache.
The work is by no means complete. The treetable editing functionality is not complete as yet. The treenodes are not editable. The swing version that I have developed is able to edit the treenodes. If time permits I would like to take that up as well. The only thing that is stopping me is the stack up inside my head has been cleared to make room for other stuff. Restarting work would mean once again going back and starting from the beginning

At times I did end up comparing wicket's syntax with that of JSF. JSF uses EL (expression language) for their expression support. JSF too uses PRopertyResolvers and with JSF our job is made slightly more difficult by ther being 2 different EL syntaxes, the JSTL syntax and JSF syntax which ofcourse is the topic of another blog altogether