Tuesday, May 14, 2013

Vaadin 7, Views and a sitemap

The Start Point

I needed to start on another application - a small one, but one which would benefit from the work I had done on V7.  So I started to build the app (and re-write some of the documentation, of which there is still more to do).

I was quite pleased with the speed with which I had a skeleton app with the core features of V7.

But I dislike writing the same code twice (or writing code once which has already been written and tested by someone else!)

I should say here that I still think Vaadin is a great product, I am just building on it for a particular set of, hopefully, common use cases. 

The "Problem"

When I looked at how I had structured V7, I could see that I was in danger of duplicating page related definitions.   There was still a strong chance of mismatches occurring between URL and View mapping, and navigation components.  And in my view, anything dependent on accurate typing of String literals is likely to cause a maintenance problem at some point.

I felt it was an improvement on the standard Vaadin 7 - but there was room for improvement. 

The Idea

The idea, then was to abstract out the structure of the site into a sitemap.  A sitemap is hardly revolutionary, but in this case it is an input rather than an output.  It acts as the specification of page layout and includes:

URL to View mapping
Packages which contain Views
URL redirection
I18NKey selection
and a fairly comprehensive report

Report

The report identifies a number of sitemap error conditions - things like missing Views, I18NKeys, redirection loops.

Generation

To be honest "Generation" is not strictly the correct word - there is no code generation, but I cannot think of a better term.  

The sitemap created from sitemap.properties is used in a Guice module to map URLs to Views, and is of course available for injection wherever needed.  One obvious use - and the reason I started on this track - is  to use the sitemap with navigation controls.

The sitemap.properties file gives quite a good description of what is needed, but yes, I need to get working on the documentation, too. 



No comments:

Post a Comment