You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Craig Tataryn <cr...@tataryn.net> on 2008/11/11 02:22:13 UTC

mounts and resources

If one were to mount a page like so:

mount(new QueryStringUrlCodingStrategy("foo/ 
HomePage.html",HomePage.class));

How would you go about having it so resources referenced in  
HomePage.html are relative to foo/ and not /?  So if there was an <img  
src="images/myimage.jpg" /> inside HomePage.html, currently the server  
would get a request for <context for webapp>/images/myimage.jpg,  
whereas the goal is to have it requested as <context of webapp>/foo/ 
images/myimage.jpg.

Thought <base href="foo/"/> would do the trick, but it didn't seem to.


Craig.

--
Craig Tataryn
site: http://www.basementcoders.com/
podcast:http://feeds.feedburner.com/TheBasementCoders
irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
im: craiger316@hotmail.com, skype: craig.tataryn


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


Re: mounts and resources

Posted by Craig Tataryn <cr...@tataryn.net>.
On 11-Nov-08, at 2:44 PM, Igor Vaynberg wrote:

> wicket always rewrites links to be context-relative. just because
> something is mounted as /foo/page doesnt mean that is the only way to
> access it. the behavior he is seeing is that his <img src="bar.gif"/>
> is rewritten as <img src="../bar.gif"/> when the page is accessed
> under its foo mount - which makes the url context-relative. this is
> the correct behavior of wicket. if he wants that url to always be
> /foo/bar.gif that is the url he should put into the markup.
>
> -igor
>

Bummer.  Ok well thanks for clearing that up, much appreciated.

Craig.

> On Tue, Nov 11, 2008 at 1:25 PM, Craig Tataryn <cr...@tataryn.net>  
> wrote:
>>
>> On 11-Nov-08, at 10:13 AM, Igor Vaynberg wrote:
>>
>>> wicket should be rewriting static urls for you so it should work
>>> transparently. what usecase exactly does not work?
>>>
>>> -igor
>>>
>>
>> Basically he has a setup like this: Apache2.2 -> Tomcat.
>>
>> He has Rewrite rules setup to make Apache serve the static content  
>> (and he
>> confirmed they worked) and a ProxyPass rule to have requests to / 
>> hiswebapp
>> served by Tomcat.
>>
>> So Apache handles all requests for:
>> /hiswebapp/images/*
>> /hiswebapp/styles/*
>> /hiswebapp/js/*
>> /hiswebapp/foo/images/*
>> /hiswebapp/foo/styles/*
>> /hiswebapp/foo/js/*
>>
>> And Tomcat handles the rest of the requests to /hiswebapp/*
>>
>> In his Wicket Application he'll do something like:
>>
>> mount(new QueryStringUrlCodingStrategy("foo/ 
>> HomePage.html",HomePage.class));
>>
>> Now in the HomePage.html file that's linked to HomePage.class he  
>> expects
>> that links to resources like <img src="images/myimage.jpg"/> should  
>> be
>> requested from the browser as "/hiswebapp/foo/images/ 
>> myimage.jpg" (because
>> of the way he mounted the page under foo)  Likewise <img
>> src="../images/anotherimage.jpg"/> should be requested as
>> /hiswebapp/images/anotherimage.jpg.  This doesn't seem to be the case
>> however.  When he tails the apache access_log he sees requests for
>> /hiswebapp/images/myimage.jpg and /images/anotherimage.jpg  
>> respectively
>> which give 404s.
>>
>> Not sure if that is enough info to go on, let me know if you need  
>> more.  If
>> you say it should work the way he expects it to, then I tell him to
>> re-examine things to see if perhaps he messed up his links or  
>> something.
>>
>> Craig.
>>
>>> On Mon, Nov 10, 2008 at 5:22 PM, Craig Tataryn <cr...@tataryn.net>
>>> wrote:
>>>>
>>>> If one were to mount a page like so:
>>>>
>>>> mount(new
>>>> QueryStringUrlCodingStrategy("foo/HomePage.html",HomePage.class));
>>>>
>>>> How would you go about having it so resources referenced in  
>>>> HomePage.html
>>>> are relative to foo/ and not /?  So if there was an <img
>>>> src="images/myimage.jpg" /> inside HomePage.html, currently the  
>>>> server
>>>> would
>>>> get a request for <context for webapp>/images/myimage.jpg,  
>>>> whereas the
>>>> goal
>>>> is to have it requested as <context of webapp>/foo/images/ 
>>>> myimage.jpg.
>>>>
>>>> Thought <base href="foo/"/> would do the trick, but it didn't  
>>>> seem to.
>>>>
>>>>
>>>> Craig.
>>>>
>>>> --
>>>> Craig Tataryn
>>>> site: http://www.basementcoders.com/
>>>> podcast:http://feeds.feedburner.com/TheBasementCoders
>>>> irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
>>>> im: craiger316@hotmail.com, skype: craig.tataryn
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>>>
>>
>> --
>> Craig Tataryn
>> site: http://www.basementcoders.com/
>> podcast:http://feeds.feedburner.com/TheBasementCoders
>> irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
>> im: craiger316@hotmail.com, skype: craig.tataryn
>>
>>
>> ---------------------------------------------------------------------
>> 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
>

--
Craig Tataryn
site: http://www.basementcoders.com/
podcast:http://feeds.feedburner.com/TheBasementCoders
irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
im: craiger316@hotmail.com, skype: craig.tataryn


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


Re: mounts and resources

Posted by Igor Vaynberg <ig...@gmail.com>.
wicket always rewrites links to be context-relative. just because
something is mounted as /foo/page doesnt mean that is the only way to
access it. the behavior he is seeing is that his <img src="bar.gif"/>
is rewritten as <img src="../bar.gif"/> when the page is accessed
under its foo mount - which makes the url context-relative. this is
the correct behavior of wicket. if he wants that url to always be
/foo/bar.gif that is the url he should put into the markup.

-igor

On Tue, Nov 11, 2008 at 1:25 PM, Craig Tataryn <cr...@tataryn.net> wrote:
>
> On 11-Nov-08, at 10:13 AM, Igor Vaynberg wrote:
>
>> wicket should be rewriting static urls for you so it should work
>> transparently. what usecase exactly does not work?
>>
>> -igor
>>
>
> Basically he has a setup like this: Apache2.2 -> Tomcat.
>
> He has Rewrite rules setup to make Apache serve the static content (and he
> confirmed they worked) and a ProxyPass rule to have requests to /hiswebapp
> served by Tomcat.
>
> So Apache handles all requests for:
> /hiswebapp/images/*
> /hiswebapp/styles/*
> /hiswebapp/js/*
> /hiswebapp/foo/images/*
> /hiswebapp/foo/styles/*
> /hiswebapp/foo/js/*
>
> And Tomcat handles the rest of the requests to /hiswebapp/*
>
> In his Wicket Application he'll do something like:
>
> mount(new QueryStringUrlCodingStrategy("foo/HomePage.html",HomePage.class));
>
> Now in the HomePage.html file that's linked to HomePage.class he expects
> that links to resources like <img src="images/myimage.jpg"/> should be
> requested from the browser as "/hiswebapp/foo/images/myimage.jpg" (because
> of the way he mounted the page under foo)  Likewise <img
> src="../images/anotherimage.jpg"/> should be requested as
> /hiswebapp/images/anotherimage.jpg.  This doesn't seem to be the case
> however.  When he tails the apache access_log he sees requests for
> /hiswebapp/images/myimage.jpg and /images/anotherimage.jpg respectively
> which give 404s.
>
> Not sure if that is enough info to go on, let me know if you need more.  If
> you say it should work the way he expects it to, then I tell him to
> re-examine things to see if perhaps he messed up his links or something.
>
> Craig.
>
>> On Mon, Nov 10, 2008 at 5:22 PM, Craig Tataryn <cr...@tataryn.net>
>> wrote:
>>>
>>> If one were to mount a page like so:
>>>
>>> mount(new
>>> QueryStringUrlCodingStrategy("foo/HomePage.html",HomePage.class));
>>>
>>> How would you go about having it so resources referenced in HomePage.html
>>> are relative to foo/ and not /?  So if there was an <img
>>> src="images/myimage.jpg" /> inside HomePage.html, currently the server
>>> would
>>> get a request for <context for webapp>/images/myimage.jpg, whereas the
>>> goal
>>> is to have it requested as <context of webapp>/foo/images/myimage.jpg.
>>>
>>> Thought <base href="foo/"/> would do the trick, but it didn't seem to.
>>>
>>>
>>> Craig.
>>>
>>> --
>>> Craig Tataryn
>>> site: http://www.basementcoders.com/
>>> podcast:http://feeds.feedburner.com/TheBasementCoders
>>> irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
>>> im: craiger316@hotmail.com, skype: craig.tataryn
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>
> --
> Craig Tataryn
> site: http://www.basementcoders.com/
> podcast:http://feeds.feedburner.com/TheBasementCoders
> irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
> im: craiger316@hotmail.com, skype: craig.tataryn
>
>
> ---------------------------------------------------------------------
> 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: mounts and resources

Posted by Craig Tataryn <cr...@tataryn.net>.
On 11-Nov-08, at 10:13 AM, Igor Vaynberg wrote:

> wicket should be rewriting static urls for you so it should work
> transparently. what usecase exactly does not work?
>
> -igor
>

Basically he has a setup like this: Apache2.2 -> Tomcat.

He has Rewrite rules setup to make Apache serve the static content  
(and he confirmed they worked) and a ProxyPass rule to have requests  
to /hiswebapp served by Tomcat.

So Apache handles all requests for:
/hiswebapp/images/*
/hiswebapp/styles/*
/hiswebapp/js/*
/hiswebapp/foo/images/*
/hiswebapp/foo/styles/*
/hiswebapp/foo/js/*

And Tomcat handles the rest of the requests to /hiswebapp/*

In his Wicket Application he'll do something like:

mount(new QueryStringUrlCodingStrategy("foo/ 
HomePage.html",HomePage.class));

Now in the HomePage.html file that's linked to HomePage.class he  
expects that links to resources like <img src="images/myimage.jpg"/>  
should be requested from the browser as "/hiswebapp/foo/images/ 
myimage.jpg" (because of the way he mounted the page under foo)   
Likewise <img src="../images/anotherimage.jpg"/> should be requested  
as /hiswebapp/images/anotherimage.jpg.  This doesn't seem to be the  
case however.  When he tails the apache access_log he sees requests  
for /hiswebapp/images/myimage.jpg and /images/anotherimage.jpg  
respectively which give 404s.

Not sure if that is enough info to go on, let me know if you need  
more.  If you say it should work the way he expects it to, then I tell  
him to re-examine things to see if perhaps he messed up his links or  
something.

Craig.

> On Mon, Nov 10, 2008 at 5:22 PM, Craig Tataryn <cr...@tataryn.net>  
> wrote:
>> If one were to mount a page like so:
>>
>> mount(new QueryStringUrlCodingStrategy("foo/ 
>> HomePage.html",HomePage.class));
>>
>> How would you go about having it so resources referenced in  
>> HomePage.html
>> are relative to foo/ and not /?  So if there was an <img
>> src="images/myimage.jpg" /> inside HomePage.html, currently the  
>> server would
>> get a request for <context for webapp>/images/myimage.jpg, whereas  
>> the goal
>> is to have it requested as <context of webapp>/foo/images/ 
>> myimage.jpg.
>>
>> Thought <base href="foo/"/> would do the trick, but it didn't seem  
>> to.
>>
>>
>> Craig.
>>
>> --
>> Craig Tataryn
>> site: http://www.basementcoders.com/
>> podcast:http://feeds.feedburner.com/TheBasementCoders
>> irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
>> im: craiger316@hotmail.com, skype: craig.tataryn
>>
>>
>> ---------------------------------------------------------------------
>> 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
>

--
Craig Tataryn
site: http://www.basementcoders.com/
podcast:http://feeds.feedburner.com/TheBasementCoders
irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
im: craiger316@hotmail.com, skype: craig.tataryn


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


Re: mounts and resources

Posted by Craig Tataryn <cr...@tataryn.net>.
Sorry, for the late response.  The premise is there are two sections  
to the site.  There is the "static section" which lives at / and the  
dynamic section that lives at /foo (controlled by wicket).  Normally  
you would just tell the container to mount the webapp to /foo and call  
it a day, but unfortunately there are two pages of .html that need to  
have some wicket and *logically* they belong in the root, not in foo.   
The rest of the root files are completely static and dished up  
directly by apache.

It's desirable to keep those two dynamic pages in / and thus have all  
their links relative to /.  My friend thought (as did I) he could do  
that by mounting the wicket webapp to / and using WebApplication's  
mount() to mount the two root pages to /PageName.html, and the rest of  
the pages from the app to /foo/PageName.html.  I know it looks like a  
bit of a screwed up situation, but it's a more of a logical thing for  
the designers (how the site is layed out logically).  The two of the  
pages really do belong in /, the rest of the site under /foo.

To answer your question, when he uses wicket to mount foo/ 
HomePage.html, inside the page there is a link to <img src"images/ 
myimage.jpg"/> that gets rewritten to ../images/myimage.jpg, which is  
undesirable from his perspective.

Craig.

On 11-Nov-08, at 10:05 PM, Johan Compagner wrote:

> I think that is what happens.
> If pages are mounted we will fix the images so that they are not
> screwed up because of the mount. What is ecactly in the html? I guess
> ../images/xxx right?
>
> On 11/11/08, Igor Vaynberg <ig...@gmail.com> wrote:
>> wicket should be rewriting static urls for you so it should work
>> transparently. what usecase exactly does not work?
>>
>> -igor
>>
>> On Mon, Nov 10, 2008 at 5:22 PM, Craig Tataryn  
>> <cr...@tataryn.net> wrote:
>>> If one were to mount a page like so:
>>>
>>> mount(new
>>> QueryStringUrlCodingStrategy("foo/HomePage.html",HomePage.class));
>>>
>>> How would you go about having it so resources referenced in  
>>> HomePage.html
>>> are relative to foo/ and not /?  So if there was an <img
>>> src="images/myimage.jpg" /> inside HomePage.html, currently the  
>>> server
>>> would
>>> get a request for <context for webapp>/images/myimage.jpg, whereas  
>>> the
>>> goal
>>> is to have it requested as <context of webapp>/foo/images/ 
>>> myimage.jpg.
>>>
>>> Thought <base href="foo/"/> would do the trick, but it didn't seem  
>>> to.
>>>
>>>
>>> Craig.
>>>
>>> --
>>> Craig Tataryn
>>> site: http://www.basementcoders.com/
>>> podcast:http://feeds.feedburner.com/TheBasementCoders
>>> irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
>>> im: craiger316@hotmail.com, skype: craig.tataryn
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

--
Craig Tataryn
site: http://www.basementcoders.com/
podcast:http://feeds.feedburner.com/TheBasementCoders
irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
im: craiger316@hotmail.com, skype: craig.tataryn


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


Re: mounts and resources

Posted by Johan Compagner <jc...@gmail.com>.
I think that is what happens.
If pages are mounted we will fix the images so that they are not
screwed up because of the mount. What is ecactly in the html? I guess
../images/xxx right?

On 11/11/08, Igor Vaynberg <ig...@gmail.com> wrote:
> wicket should be rewriting static urls for you so it should work
> transparently. what usecase exactly does not work?
>
> -igor
>
> On Mon, Nov 10, 2008 at 5:22 PM, Craig Tataryn <cr...@tataryn.net> wrote:
>> If one were to mount a page like so:
>>
>> mount(new
>> QueryStringUrlCodingStrategy("foo/HomePage.html",HomePage.class));
>>
>> How would you go about having it so resources referenced in HomePage.html
>> are relative to foo/ and not /?  So if there was an <img
>> src="images/myimage.jpg" /> inside HomePage.html, currently the server
>> would
>> get a request for <context for webapp>/images/myimage.jpg, whereas the
>> goal
>> is to have it requested as <context of webapp>/foo/images/myimage.jpg.
>>
>> Thought <base href="foo/"/> would do the trick, but it didn't seem to.
>>
>>
>> Craig.
>>
>> --
>> Craig Tataryn
>> site: http://www.basementcoders.com/
>> podcast:http://feeds.feedburner.com/TheBasementCoders
>> irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
>> im: craiger316@hotmail.com, skype: craig.tataryn
>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>

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


Re: mounts and resources

Posted by Igor Vaynberg <ig...@gmail.com>.
wicket should be rewriting static urls for you so it should work
transparently. what usecase exactly does not work?

-igor

On Mon, Nov 10, 2008 at 5:22 PM, Craig Tataryn <cr...@tataryn.net> wrote:
> If one were to mount a page like so:
>
> mount(new QueryStringUrlCodingStrategy("foo/HomePage.html",HomePage.class));
>
> How would you go about having it so resources referenced in HomePage.html
> are relative to foo/ and not /?  So if there was an <img
> src="images/myimage.jpg" /> inside HomePage.html, currently the server would
> get a request for <context for webapp>/images/myimage.jpg, whereas the goal
> is to have it requested as <context of webapp>/foo/images/myimage.jpg.
>
> Thought <base href="foo/"/> would do the trick, but it didn't seem to.
>
>
> Craig.
>
> --
> Craig Tataryn
> site: http://www.basementcoders.com/
> podcast:http://feeds.feedburner.com/TheBasementCoders
> irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
> im: craiger316@hotmail.com, skype: craig.tataryn
>
>
> ---------------------------------------------------------------------
> 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