You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Korbinian Bachl <ko...@whiskyworld.de> on 2018/04/28 08:45:59 UTC

make all links to absolute ones?

Hi,

in wicket 8 (M9) in RequestCylce there is

protected UrlRenderer newUrlRenderer()
        {
                // All URLs will be rendered relative to current request (can be overridden afterwards)
                return new UrlRenderer(getRequest());
        }

but how can I override it with a custom UrlRenderer? - I try to make all URLs to absolute ones and I tried to just override the shouldRenderAsFull with true in UrlRenderer but I cant seem to find how to make wicket use the new UrlRenderer. The only part where this is used is in ServletWebResponse as well as RequestCycle, however, RequestCycle itself is used only on Application.internalInit and the warnings there to not touch it are strong :/

Any Idea how I can override this part globally?

Best,

KB

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


Re: make all links to absolute ones?

Posted by Martin Grigorov <mg...@apache.org>.
Because relative urls:
1) are shorter, i.e. smaller responses
2) behave better when one uses proxies.

On Mon, Apr 30, 2018, 12:28 Korbinian Bachl <ko...@whiskyworld.de>
wrote:

> Thanks a lot Martin!
>
>
> I now did an quick override of it and now all URLs are absolute like I
> wanted them to be... Is there a special reason why wicket is so into this
> relative nightmare? I mean, why not just make all either absolute or
> full-URLs?
>
> I mean depending on the Url paths you get so great things like (same
> jquery, different wicket pages):
>
> <script src="/wicket/resource/[...].js"
> <script src="../wicket/resource/[...].js"
> or even
> <script src="../../wicket/resource/[...].js"
>
> Why not just use absolute URLs global by default instead?
>
>
>
>
>
> ----- Ursprüngliche Mail -----
> > Von: "Martin Grigorov" <mg...@apache.org>
> > An: users@wicket.apache.org
> > Gesendet: Samstag, 28. April 2018 13:11:49
> > Betreff: Re: make all links to absolute ones?
>
> > In MyApplication.java use setRequestCycleProvider(() -> new
> > MyRequestCycle())
> >
> > On Sat, Apr 28, 2018 at 11:45 AM, Korbinian Bachl <
> > korbinian.bachl@whiskyworld.de> wrote:
> >
> >> Hi,
> >>
> >> in wicket 8 (M9) in RequestCylce there is
> >>
> >> protected UrlRenderer newUrlRenderer()
> >>         {
> >>                 // All URLs will be rendered relative to current request
> >> (can be overridden afterwards)
> >>                 return new UrlRenderer(getRequest());
> >>         }
> >>
> >> but how can I override it with a custom UrlRenderer? - I try to make all
> >> URLs to absolute ones and I tried to just override the
> shouldRenderAsFull
> >> with true in UrlRenderer but I cant seem to find how to make wicket use
> the
> >> new UrlRenderer. The only part where this is used is in
> ServletWebResponse
> >> as well as RequestCycle, however, RequestCycle itself is used only on
> >> Application.internalInit and the warnings there to not touch it are
> strong
> >> :/
> >>
> >> Any Idea how I can override this part globally?
> >>
> >> Best,
> >>
> >> KB
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: make all links to absolute ones?

Posted by Korbinian Bachl <ko...@whiskyworld.de>.
Thanks a lot Martin!


I now did an quick override of it and now all URLs are absolute like I wanted them to be... Is there a special reason why wicket is so into this relative nightmare? I mean, why not just make all either absolute or full-URLs? 

I mean depending on the Url paths you get so great things like (same jquery, different wicket pages):

<script src="/wicket/resource/[...].js"
<script src="../wicket/resource/[...].js"
or even
<script src="../../wicket/resource/[...].js"

Why not just use absolute URLs global by default instead?





----- Ursprüngliche Mail -----
> Von: "Martin Grigorov" <mg...@apache.org>
> An: users@wicket.apache.org
> Gesendet: Samstag, 28. April 2018 13:11:49
> Betreff: Re: make all links to absolute ones?

> In MyApplication.java use setRequestCycleProvider(() -> new
> MyRequestCycle())
> 
> On Sat, Apr 28, 2018 at 11:45 AM, Korbinian Bachl <
> korbinian.bachl@whiskyworld.de> wrote:
> 
>> Hi,
>>
>> in wicket 8 (M9) in RequestCylce there is
>>
>> protected UrlRenderer newUrlRenderer()
>>         {
>>                 // All URLs will be rendered relative to current request
>> (can be overridden afterwards)
>>                 return new UrlRenderer(getRequest());
>>         }
>>
>> but how can I override it with a custom UrlRenderer? - I try to make all
>> URLs to absolute ones and I tried to just override the shouldRenderAsFull
>> with true in UrlRenderer but I cant seem to find how to make wicket use the
>> new UrlRenderer. The only part where this is used is in ServletWebResponse
>> as well as RequestCycle, however, RequestCycle itself is used only on
>> Application.internalInit and the warnings there to not touch it are strong
>> :/
>>
>> Any Idea how I can override this part globally?
>>
>> Best,
>>
>> KB
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>

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


Re: make all links to absolute ones?

Posted by Martin Grigorov <mg...@apache.org>.
In MyApplication.java use setRequestCycleProvider(() -> new
MyRequestCycle())

On Sat, Apr 28, 2018 at 11:45 AM, Korbinian Bachl <
korbinian.bachl@whiskyworld.de> wrote:

> Hi,
>
> in wicket 8 (M9) in RequestCylce there is
>
> protected UrlRenderer newUrlRenderer()
>         {
>                 // All URLs will be rendered relative to current request
> (can be overridden afterwards)
>                 return new UrlRenderer(getRequest());
>         }
>
> but how can I override it with a custom UrlRenderer? - I try to make all
> URLs to absolute ones and I tried to just override the shouldRenderAsFull
> with true in UrlRenderer but I cant seem to find how to make wicket use the
> new UrlRenderer. The only part where this is used is in ServletWebResponse
> as well as RequestCycle, however, RequestCycle itself is used only on
> Application.internalInit and the warnings there to not touch it are strong
> :/
>
> Any Idea how I can override this part globally?
>
> Best,
>
> KB
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>