Reputation: 17593
I have a web app, and it has a directory structure like:
/com/myproject/MyPage.java
/com/myproject/MyPage.html
/com/myproject/resources/styles.css
/com/myproject/resources/bg.png
In MyPage.html
I have code like:
<wicket:link>
<link rel="stylesheet" type="text/css" href="resources/styles.css"/>
</wicket:link>
The CSS file has references like url(bg.png)
. And all is good.
However, my app is now getting so big (I have about 15 pages so far), I don't want to put all the pages and HTML in one directory. However things like "styles.css" are referenced from all pages. So I would like to create various packages for various groups of pages, but still have "styles.css", and the images etc. that it references, existing only once in my source tree.
I would like to do something like:
/com/myproject/usermanagement/UserManagementStartPage.java
/com/myproject/resources/styles.css
(with the intention of sharing that between all pages)<wicket:link>
, e.g. href="../resources/styles.css"
href="/com/myproject/resources/styles.css
(that way when I move a page from one package to a deeper/shallower package, I don't have to change the number of ..
.) Am I thinking along the right lines? How would you approach this problem?
Upvotes: 1
Views: 1228
Reputation: 17533
You need something like:
<wicket:link>
<link rel="stylesheet" type="text/css" href="$up$/resources/styles.css"/>
</wicket:link>
org.apache.wicket.settings.IResourceSettings.setParentFolderPlaceholder("$up$")
This way the url will look like /com/myproject/usermanagement/$up$/resources/styles.css and Wicket will resolve the parent folder for you.
Upvotes: 2
Reputation: 434
Wicket handles CSS file links that are relative to the root of the web app. That way, it doesn't matter if you move a markup file one level higher or deeper. It is also possible to include style sheets from Java code, as explained in this article . Using markup inheritance, you can just add your style sheet to your base page and let your real pages inherit from it.
Upvotes: 2