Wicket

From Arnout Engelen

Jump to: navigation, search

Eclipse plugin: http://www.laughingpanda.org/mediawiki/index.php/Wicket_Bench

[edit] RESTful-ness

I'd like to have REST-ful, bookmarkable pages which are as type-safe as possible.

The idea is that the 'caller' could create a link to a page passing in typed parameters. 'Under water', this would get converted to a bookmarkable pagelink with PageParameters (REST-style). When clicked, the PageParameters would get converted to typed parameters again, and a typed method that does the actual construction would be called. As the code that would normally go into the constructor now goes here, but it's called (perhaps indirectly) from the Java constructor, I'll introduce a new term for this function: a RESTructor.

It'd be nice if this were as statically typed as possible.

There are 2 central methods for each restructor:

  • one to convert the parameters to something that can be made REST-ful, called by the calling code. This will have to be a static function, as there should be no need to construct the page at this point yet.
  • one to actually construct the object based on the values that have been converted from their RESTful form to their original type.

Then there is some glue that converts the PageParameters and calls the correct typed restructor.

We have to somehow tell the compiler these 2 methods should have the same type signature. I see 2 ways to do that:

  • have them implement the same interface or superclass
  • put the functionality in one method, with an added discriminator value

I'd prefer not to introduce new classes for each REST-able page, so I'll go with the latter option first.

The page constructor takes a PageParameters, and will have to determine which restructor to call. At this point we basically have only the names of the parameters. What we need is a mapping from a list of parameter names to the restructor to call. As the restructor is static, it can pass on 'this' as discriminator value. If the discriminator is null, it'll need to return the info needed to convert the values to REST and back again later. If it isn't, it may proceed in initializing this webpage.

To Be Continued ;)

Personal tools