31.WicketKatas

Overview

Code katas are exercises in programming that help you to refine your skills.  The goal of this assignment is to:
  • Improve your comfort level with Wicket by performing a number of small changes to existing Wicket systems.
Each Kata involves a modification to one of the example systems in the ICS Wicket Examples project.   To start, download the .zip distribution of all examples but example05 to your local system.  Edit the build.xml file so that the project name is no longer exampleNN, but rather exampleNN-<username>, where <username> is your uhunix account name.  Run "ant -f verify.build.xml" on each of the modified systems to make sure that it compiles and passes all quality assurance tests.

Now modify each of the example systems in the following ways.  I am guesstimating that it will require 11 hours of work to complete these 11 Katas (some should require less time, and some might require more).  After publishing your blog entries, we will find out the accuracy of this prediction!

The Eleven Wicket Katas

Example 01:

Record how long it took you to accomplish each of these katas.

Kata 1A:  Add a new line to the page that says, "In one week, the time will be <time>", where <time> is replaced by a timestamp one week later than the timestamp that now appears on the page. 

Kata 1B: Add a button to the page labelled "Refresh".  After pushing the button, the times update themselves.

Kata 1C:  Wicket, by default, runs in "Development" mode, but production systems should run in "Deployment" mode.  Override the getConfigurationType() method so that Example01 now runs in Deployment mode.  See this page for details.

When you have finished these katas, make sure they pass all quality assurance with "ant -f verify.build.xml" and that you can run the webapp by invoking "java -jar wicket-example01.jar", then create a distribution of your modified example03 with "ant -f dist.build.xml".

Example 02:

Record how long it took you to accomplish each of these katas.

Kata 2A:  Add an additional link on the home page that says, "Go to image page".   Create this page, which should display an embedded image.  This image should be G-rated.  It should be in a .jpg file stored with the system, not retrieved from the web.

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".  Hint:  each time you are pressing the button, you are changing the state of the page.  That means you need to save the state of the page in your session object, and use that state information to decide how to display the page. (Do not create three separate versions of this page with links between them!)

When you have finished these katas, make sure they pass all quality assurance with "ant -f verify.build.xml" and that you can run the webapp by invoking "java -jar wicket-example02.jar", then create a distribution of your modified example03 with "ant -f dist.build.xml".

Example 03:

Record how long it took you to accomplish each of these katas.

Kata 3A: Add a new tab called "Image" that takes the user to a page containing an embedded image (your choice, G-rated).  It should be in a .jpg file stored with the system, not retrieved from the web.  Hint: use the Image class along with the ResourceReference class to retrieve the image file from the directory containing the sources for your image page.  For example:
  • add(new Image("myImage", new ResourceReference(ImagePage.class, "myImage.jpg")));
When you have finished these katas, make sure they pass all quality assurance with "ant -f verify.build.xml" and that you can run the webapp by invoking "java -jar wicket-example03.jar", , then create a distribution of your modified example03 with "ant -f dist.build.xml".

Example 04:

Record how long it took you to accomplish each of these katas.

Kata 4A:  Add a new cheese called "Velveeta", which costs $0.25/lb. 

Kata 4B:  Add a "country" field to the billing address that appears when checking out.   The country field should provide a drop-down menu with a selection of 5 countries.

When you have finished these katas, make sure they pass all quality assurance with "ant -f verify.build.xml" and that you can run the webapp by invoking "java -jar wicket-example04.jar", then create a distribution of your modified example03 with "ant -f dist.build.xml".

Example 06:

Record how long it took you to accomplish each of these katas.

Kata 6A:  Get rid of the blue columns that appear when displaying the website. These are for development, not deployment purposes.

Kata 6B:  Place the image underneath the form, not to the right.

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

In other words, it contains a property called "deployment" whose value is true if the Wicket application should run in deployment mode, otherwise the application should run in development mode (see Kata 1C). 

Your application should read in the properties file and set the System property wicket.configuration before starting up Wicket. The Jetty class is a convenient place to do this processing.

Finally, your application should write out a message on startup indicating whether or not it found the file, and what the resulting configuration mode will be.  If the file is not found, or the property is not present in the file, then the application should run in development mode.

When you have finished these katas, make sure they pass all quality assurance with "ant -f verify.build.xml", then create a distribution of your modified example03 with "ant -f dist.build.xml".

Due date and submission instructions

By 8:00am on the date indicated on the schedule page, create a blog entry in which you discuss the concept of "code katas" and provide your opinion of them as a method for obtaining expertise in a new technology.   In addition, describe your experience with each of the 11 Wicket Katas.  For each Kata, indicate whether or not you finished it, how long it took you to do it, and what issues you ran into while doing it.  Provide a link to your distribution zip file for each system so that it can be downloaded and reviewed. If you have followed the instructions correctly, your zip file will be created with a name that includes your UH account name. (Do not simply rename the file to include your UH account name--go back and re-read the instructions so that the project itself, not only the file name, is changed.)

Finally, describe whether you observed any improvement in your Wicket development abilities over the course of this exercise.












Comments