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: [email protected]
For additional commands, e-mail: [email protected]