You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Sanket Sharma <sa...@gmail.com> on 2014/04/11 01:30:42 UTC

Getting a page URL ..

Hi,

Is there a way to get the URL of a page with request parameters in REST
format? e.g. I have a REST scheme based on the following format
http://localhost:8080/products/categoryid/productid

Is there a straightforward way for creating URLs like this? I was looking
at PageRenderLinkSource - I see it has add parameter method, but what would
be the parameter name in this case? Moreover, that generates URL in the
form of query parameters. How do I generate a REST URL?

Also, what would be the best way to replace localhost/hostname for outgoing
links? Since the application will be running behind a
firewall/loadbalancer, the hostname will not be same as publicly visible
hostname.

I was thinking of reading the hostname/internet address from a properties
file and just appending the base path to it? Is there a better way of
achieving this?


Thank you for your help.

Sanket

Re: Getting a page URL ..

Posted by Kalle Korhonen <ka...@gmail.com>.
On Thu, Apr 10, 2014 at 5:45 PM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Thu, 10 Apr 2014 20:30:42 -0300, Sanket Sharma <sa...@gmail.com>
> wrote:
>
>
>  Also, what would be the best way to replace localhost/hostname for
>> outgoing links? Since the application will be running behind a
>> firewall/loadbalancer, the hostname will not be same as publicly visible
>> hostname.
>>
>  That's called URL rewriting, specifically outgoing URL rewriting. You can
> use the built-in LinkRewriter API. Google it. ;)
>

There's no need for URL rewriting just for that. You can simply set the
hostname and port via symbols:
        configuration.add(SymbolConstants.HOSTNAME, "www.myhost.com");
        configuration.add(SymbolConstants.HOSTPORT, "80");

Kalle

Re: Getting a page URL ..

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 10 Apr 2014 20:30:42 -0300, Sanket Sharma <sa...@gmail.com>  
wrote:

> Hi,

Hi!

> Is there a way to get the URL of a page with request parameters in REST
> format?

Tapestry format, with page activation context, which you don't seem to  
know yet, is REST format already. Please read  
http://tapestry.apache.org/page-navigation.html, sections Page Render  
Request on, and the experiment with onActivate() and onPassivate().

> Is there a straightforward way for creating URLs like this? I was looking
> at PageRenderLinkSource - I see it has add parameter method, but what  
> would be the parameter name in this case? Moreover, that generates URL  
> in the
> form of query parameters. How do I generate a REST URL?

Using PageRenderLinkSource.createPageRenderLinkWithContext(...) and pass  
the appropriate page activation context.

> Also, what would be the best way to replace localhost/hostname for  
> outgoing links? Since the application will be running behind a
> firewall/loadbalancer, the hostname will not be same as publicly visible
> hostname.

That's called URL rewriting, specifically outgoing URL rewriting. You can  
use the built-in LinkRewriter API. Google it. ;)

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Getting a page URL ..

Posted by George Christman <gc...@cardaddy.com>.
I think you can just add multiple context values to your page render link
like so.

@Inject
private PageRenderLinkSource linkSource;

Link link = linkSource.createPageRenderLinkWithContext(YourPage.class,
context1, context2);

String absoluteURI = link.toAbsoluteURI();

System.out.println("URL " + absoluteURI);


On Thu, Apr 10, 2014 at 7:30 PM, Sanket Sharma <sa...@gmail.com>wrote:

> Hi,
>
> Is there a way to get the URL of a page with request parameters in REST
> format? e.g. I have a REST scheme based on the following format
> http://localhost:8080/products/categoryid/productid
>
> Is there a straightforward way for creating URLs like this? I was looking
> at PageRenderLinkSource - I see it has add parameter method, but what would
> be the parameter name in this case? Moreover, that generates URL in the
> form of query parameters. How do I generate a REST URL?
>
> Also, what would be the best way to replace localhost/hostname for outgoing
> links? Since the application will be running behind a
> firewall/loadbalancer, the hostname will not be same as publicly visible
> hostname.
>
> I was thinking of reading the hostname/internet address from a properties
> file and just appending the base path to it? Is there a better way of
> achieving this?
>
>
> Thank you for your help.
>
> Sanket
>



-- 
George Christman
www.CarDaddy.com
P.O. Box 735
Johnstown, New York