You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by angelochen <an...@yahoo.com.hk> on 2011/12/04 00:39:40 UTC
rewriting incoming linkes in the pages
Hi,
I have a page called: items/list, normal way of showing it is,
localhost:8080/items/list/0001.
thru the LinkTransformer, the incoming URL can be localhost:8080/0001/items,
works.
now all the links shown in the pages are still /items/list/0001, I'd like to
rewrite all those links to /0001/items to be consistent with incoming link,
I use following code, it says that is not a valid page name, got an idea?
thanks.
@Inject
private PageRenderLinkSource renderLinkSource;
public Link transformPageRenderLink(Link link, PageRenderRequestParameters
pageRenderRequestParameters) {
String path = link.getBasePath();
String pageName =
pageRenderRequestParameters.getLogicalPageName().toLowerCase();
if (PATH_2_CHANGE_TO.equalsIgnoreCase(pageName)) {
HashMap<String, String> info =
this.getOutgoingInfoFromPath(path);
String newPath = "/0001/items";
return renderLinkSource.createPageRenderLink(newPath);
}
return null;
--
View this message in context: http://tapestry.1045711.n5.nabble.com/rewriting-incoming-linkes-in-the-pages-tp5045427p5045427.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: rewriting incoming linkes in the pages
Posted by angelochen <an...@yahoo.com.hk>.
Seems to me DelegatingRequest and RequestFilter is for redirecting links,
what I need is rewriting the links during rendering, this can be done before
using urlrewrite service like this:
public Request process(Request request, URLRewriteContext context) {
if (context.isIncoming()) {
...
return request;
} else {
if (context.getPageParameters() != null) {
if (request.getPath().contains(".") ||
request.getPath().contains(":")) {
return request;
}
String pageName =
context.getPageParameters().getLogicalPageName().toLowerCase();
if (PATH_2_CHANGE_TO.equalsIgnoreCase(pageName)) {
String newPath = "/0001/items";
return new SimpleRequestWrapper(request, newPath);
}
}
return request;
}
}
lprimak wrote
>
> Wasn't this just discussed recently on the list?
> Something like DelegatingRequest and RequestFilter?
> I think if you search for that il help you out.
>
>
--
View this message in context: http://tapestry.1045711.n5.nabble.com/rewriting-incoming-linkes-in-the-pages-tp5045427p5045522.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: rewriting incoming linkes in the pages
Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
Wasn't this just discussed recently on the list?
Something like DelegatingRequest and RequestFilter?
I think if you search for that il help you out.
On Dec 3, 2011, at 6:39 PM, angelochen <an...@yahoo.com.hk> wrote:
> Hi,
>
> I have a page called: items/list, normal way of showing it is,
> localhost:8080/items/list/0001.
> thru the LinkTransformer, the incoming URL can be localhost:8080/0001/items,
> works.
> now all the links shown in the pages are still /items/list/0001, I'd like to
> rewrite all those links to /0001/items to be consistent with incoming link,
> I use following code, it says that is not a valid page name, got an idea?
> thanks.
>
> @Inject
> private PageRenderLinkSource renderLinkSource;
>
> public Link transformPageRenderLink(Link link, PageRenderRequestParameters
> pageRenderRequestParameters) {
> String path = link.getBasePath();
> String pageName =
> pageRenderRequestParameters.getLogicalPageName().toLowerCase();
> if (PATH_2_CHANGE_TO.equalsIgnoreCase(pageName)) {
> HashMap<String, String> info =
> this.getOutgoingInfoFromPath(path);
> String newPath = "/0001/items";
> return renderLinkSource.createPageRenderLink(newPath);
> }
>
> return null;
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/rewriting-incoming-linkes-in-the-pages-tp5045427p5045427.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org