What, you want answers too?
This page addresses general FAQ's. More specific FAQ's can be found in the FAQ Category
How do I skip the tests when doing a Maven build?
Add a -Dmaven.test.skip=true parameter to your Maven command line.
Other information about building wicket can be found on the Wicket from source page.
My span tag doesn't get rendered
If a tag's written like this,
the tag's not rendered, whereas if it's written like this
<span wicket:id="name">name</span>
it is.
The rationale is that we do not automatically convert
into
because that's too much "behind-the-scenes" magic for user to be happy with. As a result, as a
has no body, onComponentBody() isn't called and nothing is rendered!
What do you look like?
You can see some of the Wicket committers in action at the Wicket gathering in 2005 in Deventer, Holland. You'll see Eelco, Johan, Juergen, Martijn and Jonathan, and emeritus committer Chris.
What is the meaning of life, the universe and everything?
42
How can I change the location of Markup files?
Wicket reads the html template from the same location as the Page class (java class name + ".html"). Can this be changed?
Yes. See Custom resource paths
How can I have images/files uploaded to and downloaded from my wicket app?
In short, use the wicket.markup.html.form.upload.FileUploadField component in your form (set as multiPart) in order to allow file uploads. Use an implementation of the wicket.markup.html.DynamicWebResource to provide downloads of the content. For a longer description with examples see UploadDownload
Is Wicket available in the central Maven 2 repository?
Yes, it is. However, we must rely on the Maven project to update their repository with the latest releases, resulting in some lag. If you need them hot and fresh, you can use the wicket-stuff's Maven 2 repository by adding the the following to your project's pom.xml:
<repositories>
<repository>
<id>org.wicketstuff</id>
<name>Wicket Stuff Repo</name>
<url>http://wicketstuff.org/maven/repository</url>
</repository>
</repositories>
How do I add custom error pages (like Page Expired)?
In your application class that extends WebApplication, set the following in the init() method getApplicationSettings().setPageExpiredErrorPage(myExpiredPage.class). There are also some other neat settings you should check out in getApplicationSettings(), getDebugSettings(), getExceptionSettings(), getMarkupSettings(), getPageSettings(), getRequestCycleSettings(), getSecuritySettings and getSessionSettings(). See the javadoc for more information.
My application says "DEVELOPMENT MODE", how do I switch to production?
Add the following to your web.xml, inside your <servlet> mapping (or <filter> mapping if you're using 1.3.x):
<init-param>
<param-name>configuration</param-name>
<param-value>deployment</param-value>
</init-param>
You can alternatively set this as a <context-param> on the whole context.
Another option is to set the "wicket.configuration" system property to either "deployment" or "development". The value is not case-sensitive.
The system property is checked first, allowing you to add a web.xml param for deployment, and a command-line override when you want to run in development mode during development.
You may also override Application.getConfigurationType() to provide your own custom switch, in which case none of the above logic is used. See WebApplication.getConfigurationType() for the default logic used above.
How do I know in what mode (DEVELOPMENT/DEPLOYMENT) my application runs?
As of Wicket 1.3.0, you can call Application.getConfigurationType(). Prior to that, there is no flag telling you in which mode you are. If you want a flag subclass Application.configure() store the "configurationType" parameter in a variable.
if (DEVELOPMENT.equalsIgnoreCase(configurationType))
{
log.info("You are in DEVELOPMENT mode");
getResourceSettings().setResourcePollFrequency(Duration.ONE_SECOND);
getDebugSettings().setComponentUseCheck(true);
getDebugSettings().setSerializeSessionAttributes(true);
getMarkupSettings().setStripWicketTags(false);
getExceptionSettings().setUnexpectedExceptionDisplay(
UnexpectedExceptionDisplay.SHOW_EXCEPTION_PAGE);
getAjaxSettings().setAjaxDebugModeEnabled(true);
}
else if (DEPLOYMENT.equalsIgnoreCase(configurationType))
{
getResourceSettings().setResourcePollFrequency(null);
getDebugSettings().setComponentUseCheck(false);
getDebugSettings().setSerializeSessionAttributes(false);
getMarkupSettings().setStripWicketTags(true);
getExceptionSettings().setUnexpectedExceptionDisplay(
UnexpectedExceptionDisplay.SHOW_INTERNAL_ERROR_PAGE);
getAjaxSettings().setAjaxDebugModeEnabled(false);
}
I get errors when I use Ajax in Opera Browser (before Version Beta 9 of Opera)
If you want to use wicket's Ajax implementation with Opera Browser you have to do
Application.getApplicationSettings().setStripWicketTags(true);
to get it work.
Because of a Bug which is in all Opera Browsers before Version 9 Beta, the ajax stuff will not work with wicketTags enabled.
Keywords:
Opera Ajax Wicket Strip wicket:id
I get 'Internal error cloning object' errors
This is a debug feature to help find potential problems when the application runs clustered. It checks the component graphs to make sure everything is serializable (which is required for clustering).
If clustering support is not needed, these checks can be disabled by doing getDebugSettings().setSerializeSessionAttributes(false); in the application.init()
Also, if the configuration parameter in the web.xml is set to DEPLOYMENT, these checks are disabled.
Answer provided courtesy Igor Vaynberg
Which browsers have been tested with Wicket AJAX?
To test it use the AJAX examples and the AJAX request header test.
- Internet Explorer 6
- Firefox 1.5
- Firefox 2.0
- Safari 2.0.1 - 2.0.4
- Opera 8.54 (linux)
- Opera 9 (linux)
- Konqueror 3.5.2 (most of the examples works, but the Todo list example makes the browser crash)
Versioning
Wicket stores versions of pages to support the browser's back button. Because this concept is difficult to understand, we'll present a simple use case that describes the problem and how versioning helps.
Suppose you have a paging ListView with links in the ListItems, and you've clicked through to display the third page of items. On the third page, you click the link to view the details page for that item. Now, the currently available state on the server is that you were on page 3 when you clicked the link. Then you click the browser's back button twice (i.e. back to list page 3, then back to list page 2, but all in the browser). While you're on page 2, the server state is that you're on page 3. Without versioning, clicking on a ListItem link on page 2 would actually take you to the details page for an item on page 3.
(This was taken from an IRC discussion with Martijn.)
How does Wicket know when a new browser window is opened?
Wicket uses the _javascript_ window.name property to detect if a new window (or tab) was opened. This property is blank by default .
How do I provide the page map for bookmarkable pages?
You do this by providing it as part of the URL. How exactly this looks depends on the 'encoding' of the request. The common cases are (myPageMap is the page map):
- a normal request, where the page map name parameter is provided as a part of the bookmarkable page request parameter:
myapp?wicket:bookmarkablePage=myPageMap:somepackage.MyPage
- a request to a mounted URL, where the page map parameter is provided as a path encoded parameter:
/myapp/mountedpage/param1/value1/wicket:pageMapName/myPageMap
What is the future of onAttach and onDetach methods?
Igor Vaynberg in wicket-dev:
We are trying to consolidate the methods. We have a bunch of
internalOnAttach/internalAttach/attach/onattach methods. it's a big mess.
what this refactor does is give you one method you can override - onattach()
but forces the call to super.
Doing it like it has been done doesn't work. users assume onattach() is a
template method, they can override and not have to call super - but this
fails if you go more then one method deep!
if i create a custom component and do something in onattach(), then the user
subclasses it and they do something in onattach() and don't bother to call
super() they will break my functionality. My only choice of action is to
make onattach() final in my custom component and provide yet another
template for the user, onattach2() ? This just doesn't scale. Better to have
a simple and clear contract - onattach and ondetach always require the call
to super.
Unfortunately the only way to do that at this point and keep the same
method names is to do what i did.
OT there is a JSR for software defect annotations that includes something
like @MustCallSuper (forget what its called), that combined with an apt
builder in an ide will make these kinds of contracts very easy to enforce at
compile time. we are just not there just yet.
How can I use wicket to develop webapps that target mobile devices?
Write clean HTML with CSS targeted toward the various mobile clients that you wish to support. More info can be found on the Mobile Devices page.
What about performance and scalability?
Wicket performance is actually quite good under stress. Remember though that in many real-world application your bottleneck will be in business or database layer.
Wicket benchmark can be found here: wicket-1.3.x-benchmark.
You should also search wicket-user mailing list for performance and scalability or simply use performance-scalability-tipsas your starting point.
How can I keep my images (or other resources that don't need to be handled dynamically) in a directory below the root of the context?
Make the image references in your HTML be relative:
<img src=""/>
Put this in the <head></head> section of your HTML file:
<wicket:remove>
<base href="" class="code-quote">"../../../path/to/your/webapp/folder"/>
</wicket:remove>
The <base> tag will tell your browser to prepend this path to relative paths in the HTML file. The <wicket:remove> tags will tell Wicket to remove the <base> tag in the pages that it serves. Wicket's default behavior is to change relative paths in your HTML to paths relative to the context root, just as the <base> tag did when you viewed the file locally.