This is a draft document that contains a proposal for URL encoding scheme for Wicket 2.
This scheme is not implemented yet. The implementation will probably require major refactor to current URL encoding/decoding. Probably writing custom IRequestTargetResolverStrategy, IRequestCodingStrategy and new hierarchy of IRequestTargets.
Types of URLs
Bookmarkable
Bookmarkable URLs contain information necessary to create new instance of page (page class, page map). Optionally, entering a bookmarkable URL can result in immediate redirect to hybrid URL (this should be configurable per page class). Advantages of this immediate redirect is that the changes made by Ajax requests survive page refresh, which is not the case of Ajax request on bookmarkable pages with current URL scheme.
regular
- /context/?wicket:bookmarkablePage=mypackage.MyClassName¶m1=value1
mounted
- /context/my/page/class/param1/value1
- /context/my/page/class/param1/value1[:<pageMap>] (colon before pagemap name is intentional)
Hybrid
Hybrid urls contain information necessary to create new instance of page (page class), as well as concrete page instance id. Processing of hybrid urls is as follows:
- Get the page ID (and page map if specified) from URL
- Retrieve the page instance from PageMap
- If the page instance couldn't be retrieved or the page class doesn't match class specified in URL, create new page instance and redirect to new hybrid url with new page id
- Otherwise display the existing page instance
regular
- /context/?wicket:bookmarkablePage=mypackage.MyClassName¶m1=value1&wicket:interface=<pageMap>:<pageId>:<version>
mounted
- /context/my/page/class/param1/value1[<pageId>]
- /context/my/page/class/param1/value1[<pageId>:<version>]
- /context/my/page/class/param1/value1[<pageMap>:<pageId>:]
- /context/my/page/class/param1/value1[<pageMap>:<pageId>:<version>]
Bookmarkable stateless listener
This url contains information necessary to create new page instance (page class) and invoke a listener on one of page components. The page instance should be stateless and not stored in PageMap.
regular
/context/?wicket:bookmarkabePage=mypackage.MyClassName¶m1=value1&wicket:interface=<componentPath>:<listenerInterface>
mounted
/context/my/page/class/param1/value1[componentPath:listenerInterface]
HomePage
regular
hybrid
- /context/?param1=value1&wicket:interface=<pageMap>:<pageId>:<version>
stateless listener
- /context/?param1=value1&wicket:interface=<componentPath>:<listenerInterface>
Regular statefull listener
- /context/?wicket:interface=<pageMap>:<pageId>:<componentPath>:<version>:<listenerInterface>
Other thoughts
- Since homepage urls can't be mounted, we need to allow immediate redirect from homepage to bookmarkable url (do we have something like that right now?)
- How to encode '[' and ']' in page parameters for bookmarkable pages?
The immediate redirect from bookmarkable URL to hybrid URL should be suppressed when a crawler (google, msn, ...) is detected
UPDATE - this seems to raise too many concerns (although I still think it should not cause problems). We would probably just leave an extension point so that user can implement such behavior, if he wants to
Benefits when compared to current encoding strategy
- Pages with bookmarkable URLs are bookmarkable during their whole existence. Currently any action on bookmarkable page results in redirect to a non-bookmarkable URL. With the new encoding scheme, the bookmarkable url would be either immediately redirect to a hybrid url, or it would be redirected on hybrid url after first action (link clicked, etc.).
- Page changes made Ajax request would survive page refresh (if the page url is hybrid).