Wicket Routes Mount
At Code-Troopers, we like to work with the frameworks we love. One of them is Apache Wicket, and it happens to some of us doing some Play! Framework or Ruby on Rails (either for a client project, a side project or giving back OSS love).
One thing really great is this two frameworks is the central route system, one file allows to group all the routes handled by your application. Wicket does not provide such way of grouping routes, you can manually mount routes into your application or annotate your page classes.
Wicket routes mount library
This small library project available on Github
allows to group mounts into a central file. To use it, simply add
its dependency to your pom.xml
(artifact is available
on Maven central):
wicket-auth-roles
(if there is a special need for a
version without this dependency, it could be done easily).
Usage
To use it, simply create a routes.conf
file at the root
of the sources in your project (typically
src/main/resources/
) respecting the following format :
# mountPoint class roles /home codetroopers.HomePage /secured codetroopers.SecuredPage USER /user/${mode}/#{id} codetroopers.UserPage ADMIN,USER
The files content is the following :
-
Mount path : using standard Wicket syntax (
${requiredParam}
and#{optionalParam}
are available) - Page class : fully qualified name of the page class to mount
- Roles (optional) : comma separated list of roles required to access the page
ctrl+space
shortcut twice)