You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Alec Swan <al...@gmail.com> on 2012/11/05 22:09:46 UTC

Links in modal dialog are relative to dialog URL and not base page URL

Hello,

I have a base page mounted at /app/root URL. This page loads and pops
up a modal dialog (DIV) which content is loaded from /app/root/dialog
URL. All links on the dialog are relative to the dialog URL and not
base page URL. However, the browser resolves relative links against
base page URL and hence all links are broken.

The modal dialog is shown as follows:
$("#dialogId").load("/app/root/dialog").modal('show')

How can I fix this?

Thanks,

Alec

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


Re: Links in modal dialog are relative to dialog URL and not base page URL

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

The problem is trivial.
You are loading the markup of a _page_ into an element of another page.
The loaded page doesn't know that it is being included in another page and
its links doesn't count this.
See ModalWindow from wicket-extensions. It has two modes - Page and Panel.
When using a Page it renders it inside an _iframe_.


On Tue, Nov 13, 2012 at 10:40 PM, Alec Swan <al...@gmail.com> wrote:

> Martin,
>
> My original problem was in the environment without any proxies but
> relative URLs on the modal dialog loaded from jQuery were still
> broken. If you have a chance could you please review my original email
> and suggest what can be done to fix the links?
>
> Thanks,
>
> Alec
>
> On Mon, Nov 12, 2012 at 8:51 AM, Martin Grigorov <mg...@apache.org>
> wrote:
> > This is the reason why Wicket works with relative urls.
> > The absolute ones do not work well behind proxies.
> >
> >
> > On Mon, Nov 12, 2012 at 5:46 PM, Alec Swan <al...@gmail.com> wrote:
> >
> >> It turned out that
> >> RequestCycle.get().getUrlRenderer().renderFullUrl(..) always returns
> >> URL starting with http://localhost:8080 even when I deploy my on the
> >> DEV server.
> >>
> >> Has anyone experienced this issue?
> >>
> >> Thanks,
> >>
> >> Alec
> >>
> >> On Tue, Nov 6, 2012 at 9:31 AM, Alec Swan <al...@gmail.com> wrote:
> >> > To solve the problem I decided to change all my links to use absolute
> >> > URLs by overriding Link#getUrl() method as follows:
> >> >
> >> >            @Override
> >> >             protected CharSequence getURL() {
> >> >                 return
> >> >
> >>
> RequestCycle.get().getUrlRenderer().renderFullUrl(Url.parse(super.getURL().toString()));
> >> >             }
> >> >
> >> > Please let me know if there is a problem with this approach.
> >> >
> >> > Thanks,
> >> >
> >> > Alec
> >> >
> >> > On Mon, Nov 5, 2012 at 2:09 PM, Alec Swan <al...@gmail.com> wrote:
> >> >> Hello,
> >> >>
> >> >> I have a base page mounted at /app/root URL. This page loads and pops
> >> >> up a modal dialog (DIV) which content is loaded from /app/root/dialog
> >> >> URL. All links on the dialog are relative to the dialog URL and not
> >> >> base page URL. However, the browser resolves relative links against
> >> >> base page URL and hence all links are broken.
> >> >>
> >> >> The modal dialog is shown as follows:
> >> >> $("#dialogId").load("/app/root/dialog").modal('show')
> >> >>
> >> >> How can I fix this?
> >> >>
> >> >> Thanks,
> >> >>
> >> >> Alec
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> >
> > --
> > Martin Grigorov
> > jWeekend
> > Training, Consulting, Development
> > http://jWeekend.com <http://jweekend.com/>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Re: Links in modal dialog are relative to dialog URL and not base page URL

Posted by Alec Swan <al...@gmail.com>.
Martin,

My original problem was in the environment without any proxies but
relative URLs on the modal dialog loaded from jQuery were still
broken. If you have a chance could you please review my original email
and suggest what can be done to fix the links?

Thanks,

Alec

On Mon, Nov 12, 2012 at 8:51 AM, Martin Grigorov <mg...@apache.org> wrote:
> This is the reason why Wicket works with relative urls.
> The absolute ones do not work well behind proxies.
>
>
> On Mon, Nov 12, 2012 at 5:46 PM, Alec Swan <al...@gmail.com> wrote:
>
>> It turned out that
>> RequestCycle.get().getUrlRenderer().renderFullUrl(..) always returns
>> URL starting with http://localhost:8080 even when I deploy my on the
>> DEV server.
>>
>> Has anyone experienced this issue?
>>
>> Thanks,
>>
>> Alec
>>
>> On Tue, Nov 6, 2012 at 9:31 AM, Alec Swan <al...@gmail.com> wrote:
>> > To solve the problem I decided to change all my links to use absolute
>> > URLs by overriding Link#getUrl() method as follows:
>> >
>> >            @Override
>> >             protected CharSequence getURL() {
>> >                 return
>> >
>> RequestCycle.get().getUrlRenderer().renderFullUrl(Url.parse(super.getURL().toString()));
>> >             }
>> >
>> > Please let me know if there is a problem with this approach.
>> >
>> > Thanks,
>> >
>> > Alec
>> >
>> > On Mon, Nov 5, 2012 at 2:09 PM, Alec Swan <al...@gmail.com> wrote:
>> >> Hello,
>> >>
>> >> I have a base page mounted at /app/root URL. This page loads and pops
>> >> up a modal dialog (DIV) which content is loaded from /app/root/dialog
>> >> URL. All links on the dialog are relative to the dialog URL and not
>> >> base page URL. However, the browser resolves relative links against
>> >> base page URL and hence all links are broken.
>> >>
>> >> The modal dialog is shown as follows:
>> >> $("#dialogId").load("/app/root/dialog").modal('show')
>> >>
>> >> How can I fix this?
>> >>
>> >> Thanks,
>> >>
>> >> Alec
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com <http://jweekend.com/>

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


Re: Links in modal dialog are relative to dialog URL and not base page URL

Posted by Martin Grigorov <mg...@apache.org>.
This is the reason why Wicket works with relative urls.
The absolute ones do not work well behind proxies.


On Mon, Nov 12, 2012 at 5:46 PM, Alec Swan <al...@gmail.com> wrote:

> It turned out that
> RequestCycle.get().getUrlRenderer().renderFullUrl(..) always returns
> URL starting with http://localhost:8080 even when I deploy my on the
> DEV server.
>
> Has anyone experienced this issue?
>
> Thanks,
>
> Alec
>
> On Tue, Nov 6, 2012 at 9:31 AM, Alec Swan <al...@gmail.com> wrote:
> > To solve the problem I decided to change all my links to use absolute
> > URLs by overriding Link#getUrl() method as follows:
> >
> >            @Override
> >             protected CharSequence getURL() {
> >                 return
> >
> RequestCycle.get().getUrlRenderer().renderFullUrl(Url.parse(super.getURL().toString()));
> >             }
> >
> > Please let me know if there is a problem with this approach.
> >
> > Thanks,
> >
> > Alec
> >
> > On Mon, Nov 5, 2012 at 2:09 PM, Alec Swan <al...@gmail.com> wrote:
> >> Hello,
> >>
> >> I have a base page mounted at /app/root URL. This page loads and pops
> >> up a modal dialog (DIV) which content is loaded from /app/root/dialog
> >> URL. All links on the dialog are relative to the dialog URL and not
> >> base page URL. However, the browser resolves relative links against
> >> base page URL and hence all links are broken.
> >>
> >> The modal dialog is shown as follows:
> >> $("#dialogId").load("/app/root/dialog").modal('show')
> >>
> >> How can I fix this?
> >>
> >> Thanks,
> >>
> >> Alec
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Re: Links in modal dialog are relative to dialog URL and not base page URL

Posted by Alec Swan <al...@gmail.com>.
I was unable to figure this out and ended up changing the mount path
of the dialog from /root/dialog to /root-dialog in order to match the
depth of the parent page's mount path /root. I wish there was a
cleaner way to fix this.

Does anybody have any thoughts on this?

Thanks,

Alec

On Mon, Nov 12, 2012 at 8:46 AM, Alec Swan <al...@gmail.com> wrote:
> It turned out that
> RequestCycle.get().getUrlRenderer().renderFullUrl(..) always returns
> URL starting with http://localhost:8080 even when I deploy my on the
> DEV server.
>
> Has anyone experienced this issue?
>
> Thanks,
>
> Alec
>
> On Tue, Nov 6, 2012 at 9:31 AM, Alec Swan <al...@gmail.com> wrote:
>> To solve the problem I decided to change all my links to use absolute
>> URLs by overriding Link#getUrl() method as follows:
>>
>>            @Override
>>             protected CharSequence getURL() {
>>                 return
>> RequestCycle.get().getUrlRenderer().renderFullUrl(Url.parse(super.getURL().toString()));
>>             }
>>
>> Please let me know if there is a problem with this approach.
>>
>> Thanks,
>>
>> Alec
>>
>> On Mon, Nov 5, 2012 at 2:09 PM, Alec Swan <al...@gmail.com> wrote:
>>> Hello,
>>>
>>> I have a base page mounted at /app/root URL. This page loads and pops
>>> up a modal dialog (DIV) which content is loaded from /app/root/dialog
>>> URL. All links on the dialog are relative to the dialog URL and not
>>> base page URL. However, the browser resolves relative links against
>>> base page URL and hence all links are broken.
>>>
>>> The modal dialog is shown as follows:
>>> $("#dialogId").load("/app/root/dialog").modal('show')
>>>
>>> How can I fix this?
>>>
>>> Thanks,
>>>
>>> Alec

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


Re: Links in modal dialog are relative to dialog URL and not base page URL

Posted by Alec Swan <al...@gmail.com>.
It turned out that
RequestCycle.get().getUrlRenderer().renderFullUrl(..) always returns
URL starting with http://localhost:8080 even when I deploy my on the
DEV server.

Has anyone experienced this issue?

Thanks,

Alec

On Tue, Nov 6, 2012 at 9:31 AM, Alec Swan <al...@gmail.com> wrote:
> To solve the problem I decided to change all my links to use absolute
> URLs by overriding Link#getUrl() method as follows:
>
>            @Override
>             protected CharSequence getURL() {
>                 return
> RequestCycle.get().getUrlRenderer().renderFullUrl(Url.parse(super.getURL().toString()));
>             }
>
> Please let me know if there is a problem with this approach.
>
> Thanks,
>
> Alec
>
> On Mon, Nov 5, 2012 at 2:09 PM, Alec Swan <al...@gmail.com> wrote:
>> Hello,
>>
>> I have a base page mounted at /app/root URL. This page loads and pops
>> up a modal dialog (DIV) which content is loaded from /app/root/dialog
>> URL. All links on the dialog are relative to the dialog URL and not
>> base page URL. However, the browser resolves relative links against
>> base page URL and hence all links are broken.
>>
>> The modal dialog is shown as follows:
>> $("#dialogId").load("/app/root/dialog").modal('show')
>>
>> How can I fix this?
>>
>> Thanks,
>>
>> Alec

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


Re: Links in modal dialog are relative to dialog URL and not base page URL

Posted by Alec Swan <al...@gmail.com>.
To solve the problem I decided to change all my links to use absolute
URLs by overriding Link#getUrl() method as follows:

           @Override
            protected CharSequence getURL() {
                return
RequestCycle.get().getUrlRenderer().renderFullUrl(Url.parse(super.getURL().toString()));
            }

Please let me know if there is a problem with this approach.

Thanks,

Alec

On Mon, Nov 5, 2012 at 2:09 PM, Alec Swan <al...@gmail.com> wrote:
> Hello,
>
> I have a base page mounted at /app/root URL. This page loads and pops
> up a modal dialog (DIV) which content is loaded from /app/root/dialog
> URL. All links on the dialog are relative to the dialog URL and not
> base page URL. However, the browser resolves relative links against
> base page URL and hence all links are broken.
>
> The modal dialog is shown as follows:
> $("#dialogId").load("/app/root/dialog").modal('show')
>
> How can I fix this?
>
> Thanks,
>
> Alec

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