First (as always), add the tapestry-routing dependency to your pom.xml
Then annotate your pages with the @Route annotations (@At annotations are still supported and work the same way)
Let's say you have a page: pages.projects.Members which have 2 parameters in its activation context: (Long projectId, Long memberId) and you want the URL for that page to look like /projects/1/members/1
Just add the @Route annotation to you page, like this:
The RouterDispatcher will take care of recognizing incoming requests and dispatching the proper render request and the RouterLinkTransformer will do the rest of the work, it will transform every Link for a page render request formatting it according to your route rule.
CRUD and REST-like URLs
Here is an example of how tapestry-model is using tapestry-routing:
display a list of all recipies
return an HTML form for creating a new recipe
display a specific recipe
return an HTML form for editing a recipe
The only caveat with the current implementation is that you can't use Index pages. I mean pages named "*Index"
The way Tapestry handles *Index pages prevents the module from working properly.
My workaround (for now) is:
If you like to have all your routes configuration centralized, you don't need to use the @Route annotation if you don't want to. You can contribute the routes to the RouteProvider.
Avoid scanning ALL the pages.
If you want to prevent tapestry-routing from scanning all the pages packages looking for the @Route annotation set the DISABLE_AUTODISCOVERY symbol to "true". If you do this then you can either contribute your routes directly to the RouteProvider, or tell the AnnotatedPagesManager explicitly which pages do you want to be scanned.