Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Excerpt
hiddentrue

How to load templates from a location other than the classpath

Note
titleOutdated example

These examples seem to be outdated. Recommended usage for Wicket 1.1, 1.2 and 1.3 can be found on another page .

Note
titleFurther examples

An example of custom resource loading can be found in the wicket-examples, package wicket.examples.customresourceloading.

By default, Wicket loads the markup files from the Java packages. This is a good default, as it makes it possible to package components, including Pages, Panels and Borders, in a jar file, and they will still work without you having to do anything special for it!

...

Note from the above example that we overloaded method init(); If you want to use WicketServlet,
e.g. because you want to access the ServletContext object, you should do this in the init() method,
because the WicketServlet object is not set yet in the constructor.

Also note that a Path object can consist of multiple Folder object, thus making it possible to use a
mixed, layered approach.

Now, the final thing we have to do to get this working, is to place HelloWorld.html in directory
<webapp root dir>/wicket/examples/helloworld. The directory structure has to be the same as the package
structure your markup component is in.

For even more advanced uses, it is possible to provide a custom resource loading mechanism. But that is
another chapter (smile) Here is that chapter to detail a way to control where HTML files are loaded from.

...