Details

Description

Any 1.4 app that has been live for a while would likely have a collection of links pointing to it from external sites on the web. You really want the Wicket 1.5 version of your app to be able to handle any existing hybrid style links without generating an error.

The links are in the style:

/myPage/paramName1/paramValue1/paramName2/paramValue2

When migrating to 1.5, without a 1.4 compatible IPageParametersEncoder implementation, you need to include the full parameter specification in every mount if you want to avoid making changes to each individual Page class that reads parameters. The attached IPageParametersEncoder implementation means that is no longer necessary. All that is needed is to mount your pages as follows:

I'm submitting this .java file as a patch so that hopefully it may be included in future 1.5.x versions of Wicket to make it easy to implement backwards compatible URL parameter encoding for other 1.4 migrators.

Chris Colman
added a comment - 28/Sep/11 04:57 Just discovered that decodePageParameters method can cause a problem if a trailing slash is included in the URL
eg., http://www,mydomain.com/content/home/p/35/
Here's a patch to fix this:
String value = segment.next();
+ // A trailing slash can be seen as an extra segment with a "" value so check
+ // if there is a matching value for this parameter name and ignore it if not
+ if ( segment.hasNext() )
+
{
+ String value = segment.next();
+
+ parameters.add(key, value);
+ }

I haven't got any unit tests at this stage but I have thoroughly tested
in myself. The previous version worked fine so long as no trailing /
appear. I've tested that this version works without or with a trailing
slash.

I'll try to get some unit tests built when I get some spare time but
that's pretty scarce at the moment.

Chris Colman
added a comment - 28/Sep/11 06:17 I haven't got any unit tests at this stage but I have thoroughly tested
in myself. The previous version worked fine so long as no trailing /
appear. I've tested that this version works without or with a trailing
slash.
I'll try to get some unit tests built when I get some spare time but
that's pretty scarce at the moment.
compatibility
------------------------------------------------------------------------
-
https://issues.apache.org/jira/browse/WICKET-4079
collection
the
IPageParametersEncoder
to
implement
a
http://www.atlassian.com/software/jira