Hi Dave,
I should be committing some changes to the new URL Rewriting support
shortly (updating documentation at the moment); I'll be very curious
to see if the api changes (note: this is an "alpha" feature, still
subject to api change until 5.1 is declared "final") will allow you to
do what you need.
Among other things, the rewriter rules are now provided a context, and
a chance to declare whether they want to operate on incoming requests,
outgoing "requests" (link urls), or both.
The context provides information as to whether the processing is for
incoming/outgoing, and for "outgoing", it provides access to the
PageRenderRequestParameters and ComponentEventRequestParameters
objects (for page links and component event links, respectively). So
you can easily get at the page name, event name, event id, etc. when
you're rewriting links. I'm not 100% satisfied with the naming; and
I'm still deciding on whether directly exposing the request parameter
objects is the "right thing" to do. But I'll commit it to give people
a chance to give feedback.
Robert
On Apr 9, 2009, at 4/91:23 PM , Dave Greggory wrote:
We needed to contribute a custom version of LinkFactory to meet a
business need. I realize that it was internal and was subject to
change, but now that there is no LinkFactory present in 5.1 I would
like some help figuring out how to implement the same functionality.
We need to be able to specify custom URLs for Tapestry pages
(multiple URLs can go to the same Page and sometimes the same URL
can go to different tapestry Pages). Couldn't really achieve it
using activation context as the complete url needed to be
customizable. So we implemented a Dispatcher to handle it, but later
on found out that we have override the
LinkFactory.createPageRenderLink(..) functionality to get forms
working properly (action url for forms were not rendering as the
custom url without the LinkFactory).
The change we made to LinkFactory is given below. How do we do the
same in 5.1?
public Link createPageRenderLink(Page page, boolean override,
Object... pageActivationContext)
{
String logicalPageName = page.getLogicalName();
// When override is true, we use the activation context even if
empty.
Object[] context = (override || pageActivationContext.length !=
0)
? pageActivationContext
:
contextCollector.collectPageActivationContext(page);
InvocationTarget target = new PageRenderTarget(logicalPageName);
// ------------------------------- our change (begin)
----------------------------------------------
String pageUrl = (String)
request.getAttribute(OurConstants.PAGE_URL.id());
if (!StringUtils.isBlank(pageUrl))
{
while (pageUrl.startsWith("/"))
{
pageUrl = pageUrl.substring(1);
}
target = new OpaqueConstantTarget(pageUrl);
}
// ------------------------------- our change (end)
----------------------------------------------
ComponentInvocation invocation = new
ComponentInvocationImpl(contextPathEncoder, target, null, context,
false);
String baseURL = requestSecurityManager.getBaseURL(page);
Link link = new LinkImpl(response, optimizer, baseURL,
request.getContextPath(), invocation);
componentInvocationMap.store(link, invocation);
for (LinkFactoryListener listener : listeners)
listener.createdPageRenderLink(link);
return link;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org