You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Jeremy Levy (JIRA)" <ji...@apache.org> on 2007/12/04 18:57:43 UTC

[jira] Commented: (WICKET-1205) CSS relative path written out incorrectly between bookmarked and nonbookmarkable pages

    [ https://issues.apache.org/jira/browse/WICKET-1205?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12548325 ] 

Jeremy Levy commented on WICKET-1205:
-------------------------------------

Adding comments from: Oliver Lieven

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

> CSS relative path written out incorrectly between bookmarked and nonbookmarkable pages
> --------------------------------------------------------------------------------------
>
>                 Key: WICKET-1205
>                 URL: https://issues.apache.org/jira/browse/WICKET-1205
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.0-rc1
>         Environment: JBoss 4.2 / Tomcat Embedded
>            Reporter: Jeremy Levy
>            Priority: Minor
>         Attachments: CSSIssueQuickStart.tar.gz
>
>
> When linking from a bookmarked page to a non-bookmarked page the relative link to the CSS page breaks. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.