I recently came across a situation where I have to serve some static html files in a wicket application. Though it’s pretty simple, thanks to the ultra easy way wicket offers to write components, things can get tricky especially with the request path.
So I thought of documenting this for my own future reference and for the sake of the community.
Without wasting time, let me quickly explain how to serve static files with wicket (blatantly copied from wicket-examples).
Assumptions
I assume that you are using wicket 1.4.x as that’s the latest stable version at the time of writing this post.
Component
First let us write a reusable component class called “StaticLink”.
private class StaticLink extends WebMarkupContainer {
public StaticLink(String id, IModel model) {
super(id, model);
add(new AttributeModifier("href", true, model));
}
}
Html
In the html file where you want to put this link, add something like this:
<a> My static link</a>
Java
In the respective java file, all you need to do is this:
String contextPath = RequestUtils.toAbsolutePath(RequestCycle.get().
getRequest().getRelativePathPrefixToWicketHandler());
add(new StaticLink("myStaticLink", new Model(contextPath + "docs/index.html")));
Here were are resolving the absolute url of the static page which will free you from the hassles of using a relative url especially for static pages. The “contextPath” which we are constructing here will have the trailing “/” so you need not add it.



http://jamesselvakumar.wordpress.com/2008/08/01/extending-subversion-with-apache/
hi,i’m currently trying the tutorial in ur old blog
hi,when i try to save the changes made to http.conf it says the access is denied
what should i do?