urlFor(ResourceReference) strangeness

View: New views
7 Messages — Rating Filter:   Alert me  

urlFor(ResourceReference) strangeness

by Pieter Claassen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

WHen I start my application, my urlFor() returns a different URL than when I
call it a second time?

        ResourceReference iconref = new ResourceReference(anchorclass,
iconname);
        System.out.println("URL: "+urlFor(iconref));

First time it returns:
URL:
../../../resources/com.musmato.wicket.pages.styles.option1.Option1StyleAnchor/document.png

second time:
URL:
resources/com.musmato.wicket.pages.styles.option1.Option1StyleAnchor/document.png

Any ideas?

Thanks
Pieter
--

Re: urlFor(ResourceReference) strangeness

by ryantxu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

urlFor( ) uses the current request to get a relative path.  If the  
location you are calling urlFor() from changes, it will get a new  
location....

Note the only difference between the two urls is the ../../.. prefix

On Oct 27, 2009, at 11:05 AM, pieter claassen wrote:

> WHen I start my application, my urlFor() returns a different URL  
> than when I
> call it a second time?
>
>        ResourceReference iconref = new ResourceReference(anchorclass,
> iconname);
>        System.out.println("URL: "+urlFor(iconref));
>
> First time it returns:
> URL:
> ../../../resources/
> com.musmato.wicket.pages.styles.option1.Option1StyleAnchor/
> document.png
>
> second time:
> URL:
> resources/com.musmato.wicket.pages.styles.option1.Option1StyleAnchor/
> document.png
>
> Any ideas?
>
> Thanks
> Pieter
> --


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


Re: urlFor(ResourceReference) strangeness

by pieter claassen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ok, but I have a panel and I want to add an Image to the panel but when I
log into my application I get the ../../.. prefix, and the ResourceReference
then fails. However, once I click on any link, the prefix disappears and
then my panel can find the ResourceReference. Am I misunderstanding how
resource references should be used?

Thanks,
Pieter

On Tue, Oct 27, 2009 at 4:21 PM, Ryan McKinley <ryantxu@...> wrote:

> urlFor( ) uses the current request to get a relative path.  If the location
> you are calling urlFor() from changes, it will get a new location....
>
> Note the only difference between the two urls is the ../../.. prefix
>
>
> On Oct 27, 2009, at 11:05 AM, pieter claassen wrote:
>
>  WHen I start my application, my urlFor() returns a different URL than when
>> I
>> call it a second time?
>>
>>       ResourceReference iconref = new ResourceReference(anchorclass,
>> iconname);
>>       System.out.println("URL: "+urlFor(iconref));
>>
>> First time it returns:
>> URL:
>>
>> ../../../resources/com.musmato.wicket.pages.styles.option1.Option1StyleAnchor/document.png
>>
>> second time:
>> URL:
>>
>> resources/com.musmato.wicket.pages.styles.option1.Option1StyleAnchor/document.png
>>
>> Any ideas?
>>
>> Thanks
>> Pieter
>> --
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>


--
Pieter Claassen
musmato.com

Re: urlFor(ResourceReference) strangeness

by Alexandru Objelean :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am pretty sure, it is a bug. The reason why the urlFor(ResourceReference) is not working properly is because you are using BookmarkablePageRequestTargetUrlCodingStrategy for page mounting or a similar strategy which encodes the params like this: http://server/context/param1/value1/param2/value2 ... To prove that this is a bug, try to change (just for test purpose) the mounting to QueryStringUrlCodingStrategy, to make the url look like this:  http://server/context?param1=value1. I suspect that when the url is built, it depends on the page url from where the urlFor(ResourceReference) is called... and wicket doesn't remove the parameters from the url and mess this up... The real problem is when you are trying to build an absolute url for a ResourceReference. If this is indeed the reason of the problem, we should raise a jira issue...

Alex Objelean  

pieter claassen-2 wrote:
Ok, but I have a panel and I want to add an Image to the panel but when I
log into my application I get the ../../.. prefix, and the ResourceReference
then fails. However, once I click on any link, the prefix disappears and
then my panel can find the ResourceReference. Am I misunderstanding how
resource references should be used?

Thanks,
Pieter

On Tue, Oct 27, 2009 at 4:21 PM, Ryan McKinley <ryantxu@gmail.com> wrote:

> urlFor( ) uses the current request to get a relative path.  If the location
> you are calling urlFor() from changes, it will get a new location....
>
> Note the only difference between the two urls is the ../../.. prefix
>
>
> On Oct 27, 2009, at 11:05 AM, pieter claassen wrote:
>
>  WHen I start my application, my urlFor() returns a different URL than when
>> I
>> call it a second time?
>>
>>       ResourceReference iconref = new ResourceReference(anchorclass,
>> iconname);
>>       System.out.println("URL: "+urlFor(iconref));
>>
>> First time it returns:
>> URL:
>>
>> ../../../resources/com.musmato.wicket.pages.styles.option1.Option1StyleAnchor/document.png
>>
>> second time:
>> URL:
>>
>> resources/com.musmato.wicket.pages.styles.option1.Option1StyleAnchor/document.png
>>
>> Any ideas?
>>
>> Thanks
>> Pieter
>> --
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


--
Pieter Claassen
musmato.com

Re: urlFor(ResourceReference) strangeness

by pieter claassen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Alex,

The problem went away. I had some pages mounted (I landed on a mounted page)
and others not so as soon as I removed all the mounted pages, the problem
went away).

Rgds,
Pieter

On Wed, Oct 28, 2009 at 7:31 AM, Alex Objelean <alex_objelean@...>wrote:

>
> I am pretty sure, it is a bug. The reason why the urlFor(ResourceReference)
> is not working properly is because you are using
> BookmarkablePageRequestTargetUrlCodingStrategy for page mounting or a
> similar strategy which encodes the params like this:
> http://server/context/param1/value1/param2/value2 ... To prove that this
> is
> a bug, try to change (just for test purpose) the mounting to
> QueryStringUrlCodingStrategy, to make the url look like this:
> http://server/context?param1=value1. I suspect that when the url is built,
> it depends on the page url from where the urlFor(ResourceReference) is
> called... and wicket doesn't remove the parameters from the url and mess
> this up... The real problem is when you are trying to build an absolute url
> for a ResourceReference. If this is indeed the reason of the problem, we
> should raise a jira issue...
>
> Alex Objelean
>
>
> pieter claassen-2 wrote:
> >
> > Ok, but I have a panel and I want to add an Image to the panel but when I
> > log into my application I get the ../../.. prefix, and the
> > ResourceReference
> > then fails. However, once I click on any link, the prefix disappears and
> > then my panel can find the ResourceReference. Am I misunderstanding how
> > resource references should be used?
> >
> > Thanks,
> > Pieter
> >
> > On Tue, Oct 27, 2009 at 4:21 PM, Ryan McKinley <ryantxu@...>
> wrote:
> >
> >> urlFor( ) uses the current request to get a relative path.  If the
> >> location
> >> you are calling urlFor() from changes, it will get a new location....
> >>
> >> Note the only difference between the two urls is the ../../.. prefix
> >>
> >>
> >> On Oct 27, 2009, at 11:05 AM, pieter claassen wrote:
> >>
> >>  WHen I start my application, my urlFor() returns a different URL than
> >> when
> >>> I
> >>> call it a second time?
> >>>
> >>>       ResourceReference iconref = new ResourceReference(anchorclass,
> >>> iconname);
> >>>       System.out.println("URL: "+urlFor(iconref));
> >>>
> >>> First time it returns:
> >>> URL:
> >>>
> >>>
> ../../../resources/com.musmato.wicket.pages.styles.option1.Option1StyleAnchor/document.png
> >>>
> >>> second time:
> >>> URL:
> >>>
> >>>
> resources/com.musmato.wicket.pages.styles.option1.Option1StyleAnchor/document.png
> >>>
> >>> Any ideas?
> >>>
> >>> Thanks
> >>> Pieter
> >>> --
> >>>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@...
> >> For additional commands, e-mail: users-help@...
> >>
> >>
> >
> >
> > --
> > Pieter Claassen
> > musmato.com
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/urlFor%28ResourceReference%29-strangeness-tp26079363p26089957.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>


--
Pieter Claassen
musmato.com

Re: urlFor(ResourceReference) strangeness

by Alexandru Objelean :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Still, is this acceptable for you? Is my statement about mounting true? If it is, could you create a jira issue for this?

Alex

pieter claassen-2 wrote:
Alex,

The problem went away. I had some pages mounted (I landed on a mounted page)
and others not so as soon as I removed all the mounted pages, the problem
went away).

Rgds,
Pieter

On Wed, Oct 28, 2009 at 7:31 AM, Alex Objelean <alex_objelean@yahoo.com>wrote:

>
> I am pretty sure, it is a bug. The reason why the urlFor(ResourceReference)
> is not working properly is because you are using
> BookmarkablePageRequestTargetUrlCodingStrategy for page mounting or a
> similar strategy which encodes the params like this:
> http://server/context/param1/value1/param2/value2 ... To prove that this
> is
> a bug, try to change (just for test purpose) the mounting to
> QueryStringUrlCodingStrategy, to make the url look like this:
> http://server/context?param1=value1. I suspect that when the url is built,
> it depends on the page url from where the urlFor(ResourceReference) is
> called... and wicket doesn't remove the parameters from the url and mess
> this up... The real problem is when you are trying to build an absolute url
> for a ResourceReference. If this is indeed the reason of the problem, we
> should raise a jira issue...
>
> Alex Objelean
>
>
> pieter claassen-2 wrote:
> >
> > Ok, but I have a panel and I want to add an Image to the panel but when I
> > log into my application I get the ../../.. prefix, and the
> > ResourceReference
> > then fails. However, once I click on any link, the prefix disappears and
> > then my panel can find the ResourceReference. Am I misunderstanding how
> > resource references should be used?
> >
> > Thanks,
> > Pieter
> >
> > On Tue, Oct 27, 2009 at 4:21 PM, Ryan McKinley <ryantxu@gmail.com>
> wrote:
> >
> >> urlFor( ) uses the current request to get a relative path.  If the
> >> location
> >> you are calling urlFor() from changes, it will get a new location....
> >>
> >> Note the only difference between the two urls is the ../../.. prefix
> >>
> >>
> >> On Oct 27, 2009, at 11:05 AM, pieter claassen wrote:
> >>
> >>  WHen I start my application, my urlFor() returns a different URL than
> >> when
> >>> I
> >>> call it a second time?
> >>>
> >>>       ResourceReference iconref = new ResourceReference(anchorclass,
> >>> iconname);
> >>>       System.out.println("URL: "+urlFor(iconref));
> >>>
> >>> First time it returns:
> >>> URL:
> >>>
> >>>
> ../../../resources/com.musmato.wicket.pages.styles.option1.Option1StyleAnchor/document.png
> >>>
> >>> second time:
> >>> URL:
> >>>
> >>>
> resources/com.musmato.wicket.pages.styles.option1.Option1StyleAnchor/document.png
> >>>
> >>> Any ideas?
> >>>
> >>> Thanks
> >>> Pieter
> >>> --
> >>>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> >
> > --
> > Pieter Claassen
> > musmato.com
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/urlFor%28ResourceReference%29-strangeness-tp26079363p26089957.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


--
Pieter Claassen
musmato.com

Re: urlFor(ResourceReference) strangeness

by pieter claassen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Alex,

My apologies, but I cannot reproduce this issue again. Even if I mount a
page and then land on that page, I now get the correct behaviour with the
default URL encoding strategy. I am wondering if I called the correct
urlFor()? No good speculating on this though....

If I see this again, I will investigate and file a bug if needed.

Thanks for the feedback.
Pieter

On Wed, Oct 28, 2009 at 10:56 AM, Alex Objelean <alex_objelean@...>wrote:

>
> Still, is this acceptable for you? Is my statement about mounting true? If
> it
> is, could you create a jira issue for this?
>
> Alex
>
>
> pieter claassen-2 wrote:
> >
> > Alex,
> >
> > The problem went away. I had some pages mounted (I landed on a mounted
> > page)
> > and others not so as soon as I removed all the mounted pages, the problem
> > went away).
> >
> > Rgds,
> > Pieter
> >
> > On Wed, Oct 28, 2009 at 7:31 AM, Alex Objelean
> > <alex_objelean@...>wrote:
> >
> >>
> >> I am pretty sure, it is a bug. The reason why the
> >> urlFor(ResourceReference)
> >> is not working properly is because you are using
> >> BookmarkablePageRequestTargetUrlCodingStrategy for page mounting or a
> >> similar strategy which encodes the params like this:
> >> http://server/context/param1/value1/param2/value2 ... To prove that
> this
> >> is
> >> a bug, try to change (just for test purpose) the mounting to
> >> QueryStringUrlCodingStrategy, to make the url look like this:
> >> http://server/context?param1=value1. I suspect that when the url is
> >> built,
> >> it depends on the page url from where the urlFor(ResourceReference) is
> >> called... and wicket doesn't remove the parameters from the url and mess
> >> this up... The real problem is when you are trying to build an absolute
> >> url
> >> for a ResourceReference. If this is indeed the reason of the problem, we
> >> should raise a jira issue...
> >>
> >> Alex Objelean
> >>
> >>
> >> pieter claassen-2 wrote:
> >> >
> >> > Ok, but I have a panel and I want to add an Image to the panel but
> when
> >> I
> >> > log into my application I get the ../../.. prefix, and the
> >> > ResourceReference
> >> > then fails. However, once I click on any link, the prefix disappears
> >> and
> >> > then my panel can find the ResourceReference. Am I misunderstanding
> how
> >> > resource references should be used?
> >> >
> >> > Thanks,
> >> > Pieter
> >> >
> >> > On Tue, Oct 27, 2009 at 4:21 PM, Ryan McKinley <ryantxu@...>
> >> wrote:
> >> >
> >> >> urlFor( ) uses the current request to get a relative path.  If the
> >> >> location
> >> >> you are calling urlFor() from changes, it will get a new location....
> >> >>
> >> >> Note the only difference between the two urls is the ../../.. prefix
> >> >>
> >> >>
> >> >> On Oct 27, 2009, at 11:05 AM, pieter claassen wrote:
> >> >>
> >> >>  WHen I start my application, my urlFor() returns a different URL
> than
> >> >> when
> >> >>> I
> >> >>> call it a second time?
> >> >>>
> >> >>>       ResourceReference iconref = new ResourceReference(anchorclass,
> >> >>> iconname);
> >> >>>       System.out.println("URL: "+urlFor(iconref));
> >> >>>
> >> >>> First time it returns:
> >> >>> URL:
> >> >>>
> >> >>>
> >>
> ../../../resources/com.musmato.wicket.pages.styles.option1.Option1StyleAnchor/document.png
> >> >>>
> >> >>> second time:
> >> >>> URL:
> >> >>>
> >> >>>
> >>
> resources/com.musmato.wicket.pages.styles.option1.Option1StyleAnchor/document.png
> >> >>>
> >> >>> Any ideas?
> >> >>>
> >> >>> Thanks
> >> >>> Pieter
> >> >>> --
> >> >>>
> >> >>
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: users-unsubscribe@...
> >> >> For additional commands, e-mail: users-help@...
> >> >>
> >> >>
> >> >
> >> >
> >> > --
> >> > Pieter Claassen
> >> > musmato.com
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/urlFor%28ResourceReference%29-strangeness-tp26079363p26089957.html
> >> Sent from the Wicket - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@...
> >> For additional commands, e-mail: users-help@...
> >>
> >>
> >
> >
> > --
> > Pieter Claassen
> > musmato.com
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/urlFor%28ResourceReference%29-strangeness-tp26079363p26091991.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>


--
Pieter Claassen
musmato.com