You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Lidija Dolinar <li...@gmail.com> on 2014/01/02 08:59:08 UTC

How to retrieve complete current URL with context

Hi,

My page name is Najdi and I have a query parameter appended to the link so
the link looks like this: http://localhost:8080/najdi/test .

I need to remember this url because I'm redirecting user back to this page
later on when he logs in (we have a custom login page).

I'm assigning resources.getPageName(); to the session variable - in this
case the value is Najdi, so the redirection url is
http://localhost:8080/Najdi. But I also need the additional parameters -
context ("test" in the above case). It would be very nice if I could just
read the whole URL, save it into session and then redirect user back to
this url.

But I'm having difficulties getting complete url:

linkSource.createPageRenderLink(resources.getPageName(),
false).toAbsoluteURI();

returns "http://localhost:8080/Najdi".

So my question is - how can I simply retrieve complete URL with context (if
it exists), in other words, is there a simple way to get "
http://localhost:8080/najdi/test"?

Kind regards,
Lidija

Re: How to retrieve complete current URL with context

Posted by Lidija Dolinar <li...@gmail.com>.
I already have Request object injected as you specified.

My import is:
import org.apache.tapestry5.services.Request;

but it doesn't have getRequestURL() method, there's only
request.getRemoteHost().

I should probably have servletRequest injected:
@Inject
private HttpServletRequest servletRequest;

and then call servletRequest.getRequestURL(), but it doesn't give me the
"correct" url - i get "
http://localhost:8080/najdi.layoutnajdi.loginlink.prijava"
Regards,
Lidija


On Thu, Jan 2, 2014 at 9:05 AM, Matthias <th...@gmail.com> wrote:

> Hi, you could try to inject the tapestry request class.
>
> @Inject
> Request request
>
> void func()  {
>   String url = request.getRequestURL();
>
> }
>
> On 02.01.2014 08:59, Lidija Dolinar wrote:
>
>> Hi,
>>
>> My page name is Najdi and I have a query parameter appended to the link so
>> the link looks like this: http://localhost:8080/najdi/test .
>>
>> I need to remember this url because I'm redirecting user back to this page
>> later on when he logs in (we have a custom login page).
>>
>> I'm assigning resources.getPageName(); to the session variable - in this
>> case the value is Najdi, so the redirection url is
>> http://localhost:8080/Najdi. But I also need the additional parameters -
>> context ("test" in the above case). It would be very nice if I could just
>> read the whole URL, save it into session and then redirect user back to
>> this url.
>>
>> But I'm having difficulties getting complete url:
>>
>> linkSource.createPageRenderLink(resources.getPageName(),
>> false).toAbsoluteURI();
>>
>> returns "http://localhost:8080/Najdi".
>>
>> So my question is - how can I simply retrieve complete URL with context
>> (if
>> it exists), in other words, is there a simple way to get "
>> http://localhost:8080/najdi/test"?
>>
>> Kind regards,
>> Lidija
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: How to retrieve complete current URL with context

Posted by Matthias <th...@gmail.com>.
Hi, you could try to inject the tapestry request class.

@Inject
Request request

void func()  {
   String url = request.getRequestURL();
}

On 02.01.2014 08:59, Lidija Dolinar wrote:
> Hi,
>
> My page name is Najdi and I have a query parameter appended to the link so
> the link looks like this: http://localhost:8080/najdi/test .
>
> I need to remember this url because I'm redirecting user back to this page
> later on when he logs in (we have a custom login page).
>
> I'm assigning resources.getPageName(); to the session variable - in this
> case the value is Najdi, so the redirection url is
> http://localhost:8080/Najdi. But I also need the additional parameters -
> context ("test" in the above case). It would be very nice if I could just
> read the whole URL, save it into session and then redirect user back to
> this url.
>
> But I'm having difficulties getting complete url:
>
> linkSource.createPageRenderLink(resources.getPageName(),
> false).toAbsoluteURI();
>
> returns "http://localhost:8080/Najdi".
>
> So my question is - how can I simply retrieve complete URL with context (if
> it exists), in other words, is there a simple way to get "
> http://localhost:8080/najdi/test"?
>
> Kind regards,
> Lidija
>


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


Re: How to retrieve complete current URL with context

Posted by Lidija Dolinar <li...@gmail.com>.
You're right, of course :).
Sorry for the confusion - "test" string in above url represents query in
our application.

Regards,
Lidija


On Thu, Jan 2, 2014 at 12:25 PM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Thu, 02 Jan 2014 05:59:08 -0200, Lidija Dolinar <li...@gmail.com>
> wrote:
>
>  Hi,
>>
>
> Hi!
>
>
>  My page name is Najdi and I have a query parameter appended to the link
>> so the link looks like this: http://localhost:8080/najdi/test .
>>
>
> Jan already answered your question, but I'd like to add something: the URL
> above does *not* have any query parameters. It has a page activation
> context.
>
> --
> 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: How to retrieve complete current URL with context

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 02 Jan 2014 05:59:08 -0200, Lidija Dolinar <li...@gmail.com>  
wrote:

> Hi,

Hi!

> My page name is Najdi and I have a query parameter appended to the link  
> so the link looks like this: http://localhost:8080/najdi/test .

Jan already answered your question, but I'd like to add something: the URL  
above does *not* have any query parameters. It has a page activation  
context.

-- 
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: How to retrieve complete current URL with context

Posted by Lidija Dolinar <li...@gmail.com>.
Thank you!
It indeed helped :).

I added onPassivate method to Najdi page:
String onPassivate() {
  return q; // returns query parameter
}

And now I get the complete URL with the following code:
String absolute = linkSource.createPageRenderLink(resources.getPageName(),
false).toAbsoluteURI();


Regards,
Lidija


On Thu, Jan 2, 2014 at 9:16 AM, Jan Fryblik <ja...@ebrothers.cz>wrote:

>
> Hi,
>
> may be that link would help you.
>
> http://jumpstart.doublenegative.com.au/jumpstart/examples/navigation/
> returntopage1/abc
>
>
> BR,
> Jan
>
>

Re: How to retrieve complete current URL with context

Posted by Jan Fryblik <ja...@ebrothers.cz>.
Hi,

may be that link would help you.

http://jumpstart.doublenegative.com.au/jumpstart/examples/navigation/returntopage1/abc


BR,
Jan



On Thu, 02 Jan 2014 08:59:08 +0100, Lidija Dolinar <li...@gmail.com>
wrote:

> Hi,
>
> My page name is Najdi and I have a query parameter appended to the link  
> so
> the link looks like this: http://localhost:8080/najdi/test .
>
> I need to remember this url because I'm redirecting user back to this  
> page
> later on when he logs in (we have a custom login page).
>
> I'm assigning resources.getPageName(); to the session variable - in this
> case the value is Najdi, so the redirection url is
> http://localhost:8080/Najdi. But I also need the additional parameters -
> context ("test" in the above case). It would be very nice if I could just
> read the whole URL, save it into session and then redirect user back to
> this url.
>
> But I'm having difficulties getting complete url:
>
> linkSource.createPageRenderLink(resources.getPageName(),
> false).toAbsoluteURI();
>
> returns "http://localhost:8080/Najdi".
>
> So my question is - how can I simply retrieve complete URL with context  
> (if
> it exists), in other words, is there a simple way to get "
> http://localhost:8080/najdi/test"?
>
> Kind regards,
> Lidija

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