Tuesday, November 23, 2010

31. Wicket Katas


We've been tasked with modifying a few example Wicket framework projects as "katas".

Wicket expertise prior to the Katas:
I've been slowly reading through the Wicket book. I think I a vague (albeit better) understanding of the difference between the static and dynamic model system. I would say that my understanding of Wicket as of now is still pretty elementary; I am still a little unsure about the whole component/model relationship and when a component gets re-rendered. Little by little, however, and as I continue to read the book, I've acquired a better understanding of the functions and underpinnings of the framework.

Here's a link to a description of the Katas: ICS413 Wicket Katas

Kata 1A: Duration - 30 min
Kata 1B: Duration - 10 min
Kata 1C: Duration - 2 min
Kata 2A: Duration - 1 hr 15 min
Kata 2B: Duration - 4 hours
Kata 3A: Duration - 30 min
Kata 4A: Duration - 5 min
Kata 4B: Duration - 20 min
Kata 6A: Duration - 2 min
Kata 6B: Duration - 2 min
Kata 6C: Duration - 2 hrs

Total Duration: 8 hrs 16 min
ALL Katas Completed.

Distribution Versions:

For the most part, a lot of these Katas were adapting already existing code to meet the specifications and weren't all that difficult. 2B, however, took a lot more time to figure out. Here's what we were tasked to do:

Kata 2B: Add a button on the home page with the label, "Make font bold". After the user pushes it, all the text on the page should become bold, and the button label should change to "Make font italic". When the user pushes that button, all of the text should change to italic and the button label should change to "Make font normal". Pushing that button changes the text back to its original state and the button label should now say "Make font bold".



This kata really forced me to examine the interaction between what's presented on the page versus what lives in the java code. I also had to attach a CSS style attribute to the body of the page, which had nested tags, so Wicket's hierarchical structure initially caused errors in the page. After matching the hierarchy with the Java code, I was able to use the attribute modifier function to toggle between font-weight: bold/normal and font-style: italic.

Another problem that I ran into was the toggling of the styles with a submit button. This meant saving a state of some sort, which I solved through use of a session. Prior to this, the flag I used to toggle between styles would not save it's state between page refreshes.

Finally, I had to implement a child class to the Link class. For some reason or another, the button and submit classes did not refresh the page as needed. In order to change the label on the button with each click, I had to create a child class to the link class and implement this toggling of the label within the constructor.

This was by far the most difficult of the 11 assignments.

Probably the second most interesting kata was the following:

Kata 6C: It is often convenient for web applications to consult a properties file when starting up in order to get configuration values. An easy way to do this is with the standard Java Properties mechanism. (See Java in a Nutshell for details on properties file manipulation.) For this Kata, modify your Example06 system to read in a file (if present) located in ~/.example06/configuration.properties. (Note that ~ means "the user's home directory", and that there is a System property in Java that provides this value.) This property file should contain a line like the following: deployment=true

Although not really enlightening in regards to improving my familiarity with Wicket, I did learn about Properties files in Java and how they're used to configure applications. This exercise also helped me brush up on catching exceptions and opening files and streams.

Conclusion
I liked these exercises. I thought they were very do-able and the combination of having templates to work from in addition to other resources (book and Google) really helped to lessen the frustration factor.

I'm starting to appreciate the framework and it's workings. Although by no means have I mastered models, I do have a basic understanding of them as well some of the limitations that the framework presents. E.g., the need to store variables in a session in order to preserve their current values.

The Cheeser example is starting to grow on me too the more I look at it and examine what it can do.









No comments:

Post a Comment