Re: Wicket 1.5: request mapper to make all urls absolute

2011-09-19 Thread manuelbarzi
https://cwiki.apache.org/WICKET/how-to-do-things-in-wicket.html
.



On Mon, Sep 19, 2011 at 1:57 AM, Bas Gooren b...@iswd.nl wrote:

 After quite a lot of searching and testing, I've finally been able to get
 things working.

 In the end, I was able to solve my problem in the most logical place, which
 once again shows how great Wicket is!
 I've created an AbsoluteUrlRenderer (which extends the default
 UrlRenderer).

 What is a good place to share this code so other wicket users can save
 themselves the time?

 Op 16-9-2011 1:20, schreef Bas Gooren:

  Ok, I've been playing around with this, and it doesn't work.

 WebPageRenderer#respond() compares the current url to the target url.
 The current url is always normalized (without context path), so if my
 absolute mapper generates a target url which is absolute, and as such
 includes the context path and the filter path, wicket initiates a redirect.

 Then, on the next request, the exact same thing happens, so we end up in a
 redirect loop.

 It appears that the only way to achieve what I want is to override the
 UrlRenderer and it's method #renderRelativeUrl(). Basically, all that is
 required there is to prefix the context path and filter path.

 Op 15-9-2011 1:58, schreef Igor Vaynberg:

 that sounds correct.

 essentially this is the same as running the url through
 requestcycle.geturlrenderer().**renderFullUrl(url) but with a different
 prefix

 -igor

 On Wed, Sep 14, 2011 at 4:54 PM, Bas Goorenb...@iswd.nl  wrote:

 Hi,

 Another wicket 1.5 migration question:
 In 1.4 we created a IRequestCodingStrategy decorator which, in encode(),
 translates all urls to be absolute.
 We did this by checking if the url started with /, and if not,
 removing
 all occurrences of ../ and ./.

 To handle being behind a reverse proxy, the constructor optionally
 accepted
 a prefix which was always prepended.

 In 1.5 it seems this could be implemented as an IRequestMapper which
 decorates the root mapper.
 However, since we are passed a Url instead of a String, and a lot has
 changed surrounding url generation, what is the best way to make all
 urls
 absolute?

 I'm thinking:
 - check Url.isAbsolute()
 - remove segments which are .. or .
 - prepend prefix segments

 Is this the correct way?

 Sebastian

  --**--**
 -
 To unsubscribe, e-mail: 
 users-unsubscribe@wicket.**apache.orgusers-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org





Re: Wicket 1.5: request mapper to make all urls absolute

2011-09-19 Thread Bas Gooren

Ok, I've added it.

See https://cwiki.apache.org/confluence/display/WICKET/Request+mapping
Or https://cwiki.apache.org/WICKET/request-mapping.html when it's updated.

Thanks for the pointer.

Op 19-9-2011 9:09, schreef manuelbarzi:

https://cwiki.apache.org/WICKET/how-to-do-things-in-wicket.html
.



On Mon, Sep 19, 2011 at 1:57 AM, Bas Goorenb...@iswd.nl  wrote:


After quite a lot of searching and testing, I've finally been able to get
things working.

In the end, I was able to solve my problem in the most logical place, which
once again shows how great Wicket is!
I've created an AbsoluteUrlRenderer (which extends the default
UrlRenderer).

What is a good place to share this code so other wicket users can save
themselves the time?

Op 16-9-2011 1:20, schreef Bas Gooren:

  Ok, I've been playing around with this, and it doesn't work.

WebPageRenderer#respond() compares the current url to the target url.
The current url is always normalized (without context path), so if my
absolute mapper generates a target url which is absolute, and as such
includes the context path and the filter path, wicket initiates a redirect.

Then, on the next request, the exact same thing happens, so we end up in a
redirect loop.

It appears that the only way to achieve what I want is to override the
UrlRenderer and it's method #renderRelativeUrl(). Basically, all that is
required there is to prefix the context path and filter path.

Op 15-9-2011 1:58, schreef Igor Vaynberg:


that sounds correct.

essentially this is the same as running the url through
requestcycle.geturlrenderer().**renderFullUrl(url) but with a different
prefix

-igor

On Wed, Sep 14, 2011 at 4:54 PM, Bas Goorenb...@iswd.nl   wrote:


Hi,

Another wicket 1.5 migration question:
In 1.4 we created a IRequestCodingStrategy decorator which, in encode(),
translates all urls to be absolute.
We did this by checking if the url started with /, and if not,
removing
all occurrences of ../ and ./.

To handle being behind a reverse proxy, the constructor optionally
accepted
a prefix which was always prepended.

In 1.5 it seems this could be implemented as an IRequestMapper which
decorates the root mapper.
However, since we are passed a Url instead of a String, and a lot has
changed surrounding url generation, what is the best way to make all
urls
absolute?

I'm thinking:
- check Url.isAbsolute()
- remove segments which are .. or .
- prepend prefix segments

Is this the correct way?

Sebastian

  --**--**

-
To unsubscribe, e-mail: 
users-unsubscribe@wicket.**apache.orgusers-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




Re: Wicket 1.5: request mapper to make all urls absolute

2011-09-19 Thread manuelbarzi
cool. may you add this how-to code-example for wicket 1.4 too?
coincidentally, i may need it to test something here... ;-)


On Mon, Sep 19, 2011 at 1:48 PM, Bas Gooren b...@iswd.nl wrote:

 Ok, I've added it.

 See 
 https://cwiki.apache.org/**confluence/display/WICKET/**Request+mappinghttps://cwiki.apache.org/confluence/display/WICKET/Request+mapping
 Or 
 https://cwiki.apache.org/**WICKET/request-mapping.htmlhttps://cwiki.apache.org/WICKET/request-mapping.htmlwhen
  it's updated.

 Thanks for the pointer.

 Op 19-9-2011 9:09, schreef manuelbarzi:

 https://cwiki.apache.org/**WICKET/how-to-do-things-in-**wicket.htmlhttps://cwiki.apache.org/WICKET/how-to-do-things-in-wicket.html
 .



 On Mon, Sep 19, 2011 at 1:57 AM, Bas Goorenb...@iswd.nl  wrote:

  After quite a lot of searching and testing, I've finally been able to get
 things working.

 In the end, I was able to solve my problem in the most logical place,
 which
 once again shows how great Wicket is!
 I've created an AbsoluteUrlRenderer (which extends the default
 UrlRenderer).

 What is a good place to share this code so other wicket users can save
 themselves the time?

 Op 16-9-2011 1:20, schreef Bas Gooren:

  Ok, I've been playing around with this, and it doesn't work.

 WebPageRenderer#respond() compares the current url to the target url.
 The current url is always normalized (without context path), so if my
 absolute mapper generates a target url which is absolute, and as such
 includes the context path and the filter path, wicket initiates a
 redirect.

 Then, on the next request, the exact same thing happens, so we end up in
 a
 redirect loop.

 It appears that the only way to achieve what I want is to override the
 UrlRenderer and it's method #renderRelativeUrl(). Basically, all that is
 required there is to prefix the context path and filter path.

 Op 15-9-2011 1:58, schreef Igor Vaynberg:

  that sounds correct.

 essentially this is the same as running the url through
 requestcycle.geturlrenderer().renderFullUrl(url) but with a
 different
 prefix

 -igor

 On Wed, Sep 14, 2011 at 4:54 PM, Bas Goorenb...@iswd.nl   wrote:

  Hi,

 Another wicket 1.5 migration question:
 In 1.4 we created a IRequestCodingStrategy decorator which, in
 encode(),
 translates all urls to be absolute.
 We did this by checking if the url started with /, and if not,
 removing
 all occurrences of ../ and ./.

 To handle being behind a reverse proxy, the constructor optionally
 accepted
 a prefix which was always prepended.

 In 1.5 it seems this could be implemented as an IRequestMapper which
 decorates the root mapper.
 However, since we are passed a Url instead of a String, and a lot has
 changed surrounding url generation, what is the best way to make all
 urls
 absolute?

 I'm thinking:
 - check Url.isAbsolute()
 - remove segments which are .. or .
 - prepend prefix segments

 Is this the correct way?

 Sebastian

  --**--**

 -
 To unsubscribe, e-mail: 
 users-unsubscribe@wicket.**apa**che.orghttp://apache.org
 users-unsubscribe@**wicket.apache.orgusers-unsubscr...@wicket.apache.org
 

 For additional commands, e-mail: users-h...@wicket.apache.org





Re: Wicket 1.5: request mapper to make all urls absolute

2011-09-18 Thread Bas Gooren
After quite a lot of searching and testing, I've finally been able to 
get things working.


In the end, I was able to solve my problem in the most logical place, 
which once again shows how great Wicket is!

I've created an AbsoluteUrlRenderer (which extends the default UrlRenderer).

What is a good place to share this code so other wicket users can save 
themselves the time?


Op 16-9-2011 1:20, schreef Bas Gooren:

Ok, I've been playing around with this, and it doesn't work.

WebPageRenderer#respond() compares the current url to the target url.
The current url is always normalized (without context path), so if my 
absolute mapper generates a target url which is absolute, and as such 
includes the context path and the filter path, wicket initiates a 
redirect.


Then, on the next request, the exact same thing happens, so we end up 
in a redirect loop.


It appears that the only way to achieve what I want is to override the 
UrlRenderer and it's method #renderRelativeUrl(). Basically, all that 
is required there is to prefix the context path and filter path.


Op 15-9-2011 1:58, schreef Igor Vaynberg:

that sounds correct.

essentially this is the same as running the url through
requestcycle.geturlrenderer().renderFullUrl(url) but with a different
prefix

-igor

On Wed, Sep 14, 2011 at 4:54 PM, Bas Goorenb...@iswd.nl  wrote:

Hi,

Another wicket 1.5 migration question:
In 1.4 we created a IRequestCodingStrategy decorator which, in 
encode(),

translates all urls to be absolute.
We did this by checking if the url started with /, and if not, 
removing

all occurrences of ../ and ./.

To handle being behind a reverse proxy, the constructor optionally 
accepted

a prefix which was always prepended.

In 1.5 it seems this could be implemented as an IRequestMapper which
decorates the root mapper.
However, since we are passed a Url instead of a String, and a lot has
changed surrounding url generation, what is the best way to make all 
urls

absolute?

I'm thinking:
- check Url.isAbsolute()
- remove segments which are .. or .
- prepend prefix segments

Is this the correct way?

Sebastian


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org





Re: Wicket 1.5: request mapper to make all urls absolute

2011-09-15 Thread Bas Gooren

Ok, I've been playing around with this, and it doesn't work.

WebPageRenderer#respond() compares the current url to the target url.
The current url is always normalized (without context path), so if my 
absolute mapper generates a target url which is absolute, and as such 
includes the context path and the filter path, wicket initiates a redirect.


Then, on the next request, the exact same thing happens, so we end up in 
a redirect loop.


It appears that the only way to achieve what I want is to override the 
UrlRenderer and it's method #renderRelativeUrl(). Basically, all that is 
required there is to prefix the context path and filter path.


Op 15-9-2011 1:58, schreef Igor Vaynberg:

that sounds correct.

essentially this is the same as running the url through
requestcycle.geturlrenderer().renderFullUrl(url) but with a different
prefix

-igor

On Wed, Sep 14, 2011 at 4:54 PM, Bas Goorenb...@iswd.nl  wrote:

Hi,

Another wicket 1.5 migration question:
In 1.4 we created a IRequestCodingStrategy decorator which, in encode(),
translates all urls to be absolute.
We did this by checking if the url started with /, and if not, removing
all occurrences of ../ and ./.

To handle being behind a reverse proxy, the constructor optionally accepted
a prefix which was always prepended.

In 1.5 it seems this could be implemented as an IRequestMapper which
decorates the root mapper.
However, since we are passed a Url instead of a String, and a lot has
changed surrounding url generation, what is the best way to make all urls
absolute?

I'm thinking:
- check Url.isAbsolute()
- remove segments which are .. or .
- prepend prefix segments

Is this the correct way?

Sebastian


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Wicket 1.5: request mapper to make all urls absolute

2011-09-14 Thread Bas Gooren

Hi,

Another wicket 1.5 migration question:
In 1.4 we created a IRequestCodingStrategy decorator which, in encode(), 
translates all urls to be absolute.
We did this by checking if the url started with /, and if not, 
removing all occurrences of ../ and ./.


To handle being behind a reverse proxy, the constructor optionally 
accepted a prefix which was always prepended.


In 1.5 it seems this could be implemented as an IRequestMapper which 
decorates the root mapper.
However, since we are passed a Url instead of a String, and a lot has 
changed surrounding url generation, what is the best way to make all 
urls absolute?


I'm thinking:
- check Url.isAbsolute()
- remove segments which are .. or .
- prepend prefix segments

Is this the correct way?

Sebastian


Re: Wicket 1.5: request mapper to make all urls absolute

2011-09-14 Thread Igor Vaynberg
that sounds correct.

essentially this is the same as running the url through
requestcycle.geturlrenderer().renderFullUrl(url) but with a different
prefix

-igor

On Wed, Sep 14, 2011 at 4:54 PM, Bas Gooren b...@iswd.nl wrote:
 Hi,

 Another wicket 1.5 migration question:
 In 1.4 we created a IRequestCodingStrategy decorator which, in encode(),
 translates all urls to be absolute.
 We did this by checking if the url started with /, and if not, removing
 all occurrences of ../ and ./.

 To handle being behind a reverse proxy, the constructor optionally accepted
 a prefix which was always prepended.

 In 1.5 it seems this could be implemented as an IRequestMapper which
 decorates the root mapper.
 However, since we are passed a Url instead of a String, and a lot has
 changed surrounding url generation, what is the best way to make all urls
 absolute?

 I'm thinking:
 - check Url.isAbsolute()
 - remove segments which are .. or .
 - prepend prefix segments

 Is this the correct way?

 Sebastian


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org