Hi, I encountered this problem a week ago, too, and digged a little into code
and forum. Here's my summary:

the problem seems to be the "/*" filter mapping. If you specify a "/app/*"
filter mapping, relative URLs work just fine.
       
In my base-page-class (all my pages are derived from it through Wicket's
great markup inheritance) my stylesheet is referenced  in the head-section
by a relative reference like

   <link rel="stylesheet" type="text/css" href="style/myapp.css" />

Checking the generated HTML in the browser (when using "/*" filter mapping)
shows that this reference is modified by Wicket, so that it now reads
   
   <link rel="stylesheet" type="text/css" href="../style/myapp.css" />

This is an invalid path and addresses a wrong location.

I digged into the code and found that relative stylesheet and image
references where
automatically prepended by "../" by
ServletWebRequest.getRelativePathPrefixToContextRoot().

This seems to work well for the "/app/*" filter mapping, but fails for "/*"
(since theres no parent-directory in between to skip)

I currently decided to use the "/app/*" filter mapping.


Following workarounds came into my mind:

1. use of "absolute" references like "/myapp/style/myapp.css". 
   pro:  works, Wicket doesn't modify the absolute paths
   cons: must code the context-path into all style and image references,
which is a "NO GO"
   
2. use of "/app/*" filter mapping
   pro : works
   cons: after having seen the much nicer "/*" mapping I want to use it :-))
   
3. in HTML it is possible to add a <base
href="http://localhost:8080/myapp/"/>
   line into the head section, which is used to resolve all relative
references
   pro : would be great, since it allows the use of relative URLs, and it
must 
         be configured in just one place (the base-page's head section)
         would also be great to use when using a front end server (Apache),
         since references would be resolved to root context
   cons: since Wicket isn't aware of the <base> tag, relative references
         are still modified and prepended by "../", so no stylesheets/images
were found

4. fix it :-))

Related threads and infos:         
- "is it a bug" - use of /* filter mapping -
http://www.nabble.com/is-it-a-bug--%28using-beta-4%29-tf4649929.html#a13284326  
  

- "Wicket behind a frontend proxy" -
http://www.nabble.com/Wicket-behind-a-front-end-proxy-t4776982.html

-
http://cwiki.apache.org/WICKET/best-practices-and-gotchas.html#BestPracticesandGotchas-WicketServletMapping




Jeremy Levy-3 wrote:
> 
> WICKET-1205
> 
> On Dec 3, 2007 5:16 PM, Jeremy Levy <[EMAIL PROTECTED]> wrote:
> 
>> Sorry for now explaining this properly. My application is deployed within
>> a context of "/1".  The Wicket filter is mapped to "/*" of the app
>> context.
>>
>> The first page of the site has url of
>> http://www.somehost.com/1/welcomewhere "welcome" is mounted as a
>> bookmarkable page.  There is a link from the
>> "welcome" page to a page that isn't bookmarked.  The relative path of the
>> CSS is incorrect on the page that isn't mounted as a bookmarkable page. 
>> If
>> I make it bookmarkable the path to the CSS its correct.
>>
>> I'm going to create a quickstart project to demonstrate it and log a bug.
>>
>> J
>>
>>
>>
>>
>>
>> On Dec 3, 2007 4:40 PM, Johan Compagner <[EMAIL PROTECTED]> wrote:
>>
>> > huh? i must be missing something here.
>> > you say to the first that it works and to the second that it doesn't
>> > if /1 is the context then would say the first is broken and the second
>> > should work.
>> >
>> > because the first the url is this:
>> >
>> > localhost/css/style.css
>> >
>> > but thats outside of the context.
>> >
>> > the second it seems to be
>> >
>> > localhost/1/css/xxx
>> >
>> > and that seems ok then
>> >
>> > But it is still strange that those 2 pages give different urls because
>> > both
>> > should be css/ as far as i see
>> > because they are on both on the same level.
>> >
>> > Please make a jira issue for this
>> >
>> > johan
>> >
>> >
>> >
>> > On Dec 3, 2007 4:08 PM, Jeremy Levy < [EMAIL PROTECTED]> wrote:
>> >
>> > > The /1 is the web app context.
>> > >
>> > > Change it to ../ breaks it on the pages that were working before.
>> > >
>> > > One thing I noticed is that if I deploy this to a server which has
>> > > mod_proxy
>> > > set up to hide the /1 it seems to work fine.
>> > >
>> > > j
>> > >
>> > > On Dec 3, 2007 4:10 AM, Johan Compagner <[EMAIL PROTECTED] >
>> wrote:
>> >
>> > >
>> > > > and /1/ is your servlyet path?
>> > > > what happens if you put "../css/style.css" in your markup?
>> > > >
>> > > > Because from the normal page that is the css you want i guess?
>> > > >
>> > > > johan
>> > > >
>> > > >
>> > > >
>> > > > On Dec 2, 2007 11:08 PM, Jeremy Levy <[EMAIL PROTECTED]> wrote:
>> > > >
>> > > > > I just upgraded to Wicket 1.3, it was remarkably smooth.  It took
>> > > about
>> > > > 6
>> > > > > hours overall.  Every single thing was explained very well in the
>> > > > > migration
>> > > > > guide and the things i was looking forward to in 1.3 are working
>> > > > > perfectly.
>> > > > >
>> > > > > The only issue I am having is if I have a page this is not
>> mounted
>> > as
>> > > a
>> > > > > bookmarkable page the relative paths for my stylesheet and other
>> > > > resources
>> > > > > are written out incorrect.  Below are examples for the same page
>> > if I
>> > > > > mount
>> > > > > the page versus not.
>> > > > >
>> > > > >
>> > > > > *Bookmarked Page URL (works):*
>> > > > > http://localhost/1/gettingstarted
>> > > > >
>> > > > > <link rel="stylesheet" type="text/css" href="../css/style.css"/>
>> > > > >
>> > > > >
>> > > > > *Nonbookmarked Page URL (doesn't work):
>> > > > > *
>> > > > >
>> > > > >
>> > > >
>> > >
>> >
>> http://localhost/1/?x=5uwbo6kafiblurBY3bq1UEFwOyXneRheYz2FfwYwMiQAxP5GPHI1HfUHBUhydOCe
>> > > > >
>> > > > > <link rel="stylesheet" type="text/css" href="css/style.css"/>
>> > > > >
>> > > > >
>> > > > > *As it's written in my base page html:*
>> > > > > <link rel="stylesheet" type="text/css" href="css/style.css"/>
>> > > > >
>> > > > > Is this something I missed in the migration, or a left over, bug
>> > > maybe?
>> > > > >
>> > > > > Jeremy
>> > > > >
>> > > >
>> > >
>> >
>>
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Wicket-1.3-rc1-Relative-URLs-not-working-properly-tf4933399.html#a14150416
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to