Thursday, November 18, 2010

Wicket Chart

For this week's assignment we were exposed to a Apache Wicket,  which which is a web application framework that allows you to do web programming in Java.

Initial Thoughts
This was the first time I had ever heard of Wicket.  As a novice web developer, it reminded me a lot of PHP.  Similar to PHP, Wicket uses a model-view-controller (MVC) architecture.   Wicket interacts with an application server (in my case I am using Jetty) which then uses Java code that is on the web server to handle the Wicket requests.  The server returns the output which is viewed by the user.

From a development standpoint, I feel it can be a very slow process waiting for Java code to compile, whereas working with a scripting language like PHP gives immediate results.  But being able to have the strength of a full programming language behind your web application allows for many options that are not available to scripting languages.

Wicket Chart (Download)

This was my first web application I've created using Wicket.  The idea is to allow the user to modify a Google visualization (in this case a GoogleOMeter) through the web application.

Setup
  1. Open up the directory and run the command: %ant -f build.xml
  2. Once the installation is complete run the command: %ant run
  3. Open a web browser and go to the url: http://localhost:7070/Wicket-Chart

Once the program you have Jetty running, you're ready to view the web application.  It is a single web page that will have a form filled with preset values.  After modifying the field values, you can view the changes to the graph by clicking the 'Submit' button at the bottom of the form.  This will refresh the page and update the fields and image to reflect the changes.

Testing
There are a few simple checks that my program covers when the user inputs.  My program will check to make sure that the user has filled in the values.  If the fields are left empty, they should default to 0.  Another check I implemented was to check to make sure that the min value was indeed smaller than the max value.  In the case that this test fails the min and max value will be set to 0 and 100 respectively.  If the value does not fall between the min and max value it will be assigned to one of the ends.

The final feature that my program provides the user is an automatic scaling system.  Google restricts their images to:
  • 1 px ≤ width/height ≤ 1000 px
  • width * height ≤ 30000 px
If an image is too large, Google will usually throw an error that looks like this:
Usually the user would get an invalid image, but I tried to implement a simple check that will scale images down to an acceptable range, while keeping the dimensions proportional.

No comments:

Post a Comment