Adrian Smith
Adrian Smith

Reputation: 17593

Wicket - <wicket:link> - How to put pages in different packages?

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:

Am I thinking along the right lines? How would you approach this problem?

Upvotes: 1

Views: 1228

Answers (2)

martin-g
martin-g

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

reinouts
reinouts

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

Related Questions