Search code examples
tapestry

How can I control which URL <t:pagelink> renders?


Background

Tapestry's pagelink component shortens the logical name of a page to a nice and handy URL.

For example (found in the Tapestry Documentation), if the page class is org.example.pages.address.CreateAddress, the URL rendered by pagelink renders a link to https://<host>/address/create. That is, the redundant "Address" is removed as a suffix.

Problem

I really like this feature, yet it causes a problem when the page class name contains the name of a sub-package.

For example, org.example.pages.member.MembershipProfile results in https://<host>/member/shipprofile. The link works but the URL looks scilly and not carefully designed.

Is there a way to configure this behavior, like defining exceptions somehow, to get the URL to be https://<host>/member/membershipprofile?

Workaround

As a workaround, one can code plain HTML like so <a href="https://<host>/member/membershipprofile">...</a>. This works, but is less convenient, especially when including context.

Thank you in advance for any suggestions.


Solution

  • I don't think you can change this behaviour without overriding core services.

    You could also rename MembershipProfile to Profile, or use http://www.tynamo.org/tapestry-routing+guide/ to provide custom URL mappings if rename is not an option.