DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

  1. DZone
  2. Refcards
  3. Getting Started with Apache Wicket
refcard cover
Refcard #063

Getting Started with Apache Wicket

Creating Standard Wicket Components

Covers how to configure the framework, define your domain model, create standard Wicket components and add internationalization options.

Download Refcard
Free PDF for Easy Reference
refcard cover

Written By

author avatar Andrew Lombardi
Owner, Mystic Coders, LLC
Table of Contents
► About Apache Wicket ► Project Layout ► Configuring the Web Application ► Models ► Components ► Page and Navigation ► Markup ► Form ► Internationalization
Section 1

About Apache Wicket

By Andrew Lombardi

Apache Wicket is a Java-based web application framework that has rapidly grown to be a favorite among many developers. It features a POJO data model, no XML, and a proper mark-up / logic separation not seen in most frameworks. Apache Wicket gives you a simple framework for creating powerful, reusable components and offers an object oriented methodology to web development while requiring only Java and HTML. This Refcard covers Apache Wicket 1.3 and describes common configuration, models, the standard components, implementation of a form, the markup and internationalization options available.

Section 2

Project Layout

The project layout most typical of Apache Wicket applications is based on the default Maven directories. Any Wicket component that requires view markup in the form of HTML needs to be side-by-side with the Java file. Using Maven however, we can separate the source directories into java/ and resources/ to give some distinction. To get started, download either the wicket-quickstart project and modify it to your needs, or use the maven archetype here:

​x
1
​
2
mvn archetype:create \
3
-DarchetypeGroupId=org.apache.wicket \
4
-DarchetypeArtifactId=wicket-archetype-quickstart \
5
-DarchetypeVersion=1.3.5 \
6
-DgroupId=com.mysticcoders.refcardmaker \
7
-DartifactId=refcardmaker
8
​

Either way, if using Maven, you’ll need the wicket jar, and the latest slf4j jar.

12
1
​
2
<dependency>
3
  <groupId>org.apache.wicket</groupId>
4
  <artifactId>wicket</artifactId>
5
  <version>1.3.6</version>
6
</dependency>
7
<dependency>
8
  <groupId>org.slf4j</groupId>
9
  <artifactId>slf4j-api</artifactId>
10
  <version>1.4.2</version>
11
</dependency>
12
​
Section 3

Configuring the Web Application

I mentioned that Wicket has no XML, and that’s mostly true, but J2EE requires a web.xml file to do anything. We set up the WicketFilter and point it to our implementation of WebApplication along with the URL mapping.

7
1
​
2
<web-app>
3
  <filter>
4
    <filter-name>wicketFilter</filter-name>
5
    <filter-class>org.apache.wicket.protocol.http.
6
WicketFilter</filter-class>
7
​
17
1
​
2
<init-param>
3
      <param-name>applicationClassName</param-name>
4
      <param-value>com.mysticcoders.refcardmaker.
5
RefcardApplication</param-value>
6
    </init-param>
7
    <init-param>
8
      <param-name>filterPath</param-name>
9
      <param-value>/*</param-value>
10
    </init-param>
11
  </filter>
12
  <filter-mapping>
13
    <filter-name>wicketFilter</filter-name>
14
    <url-pattern>/*</url-pattern>
15
  </filter-mapping>
16
</web-app>
17
​

Apache Wicket offers a development and deployment mode that can be configured in the web.xml file:

6
1
​
2
<context-param>
3
  <param-name>configuration</param-name>
4
  <param-value>development</param-value>
5
</context-param>
6
​

Hot Tip

Depending on your configuration needs, you can set this parameter in the web.xml as either:
  • a context-param or init-param to the filter
  • a command line parameter wicket.configuration
  • by overriding Application.getConfigurationType()
Section 4

Models

Apache Wicket uses models to separate the domain layer from the view layer in your application and to bind them together. Components can retrieve data from their model, and convert and store data in the model upon receiving an event. There are a variety of implementations of Model, and they all extend from the interface IModel.

IModel

There are only two methods that a class would have to implement to be a Model, and that is getObject and setObject. getObject returns the value from the model, and setObject sets the value of the model. Your particular implementation of IModel can get data from wherever you’d like; the Component in the end only requires the ability to get and set the value. Every component in Wicket has a Model: some use it, some don’t, but it’s always there.

PropertyModel

A model contains a domain object, and it’s common practice to follow JavaBean conventions. The PropertyModel allows you to use a property expression to access a property in your domain object. For instance if you had a model containing Person and it had a getter/setter for firstName to access this property, you would pass the String “firstName” to that Model.

CompoundPropertyModel

An even fancier way of using models is the CompoundPropertyModel. Since most of the time, the property identifier you would give Wicket mimics that of the JavaBean property, this Model takes that implied association and makes it work for you.

8
1
​
2
...
3
setModel(new CompoundPropertyModel(person));
4
add(new Label(“firstName”));
5
add(new Label(“lastName”));
6
add(new Label(“address.address1”));
7
...
8
​

We can see from the example above, that if we set the model with the person object using a CompoundPropertyModel, the corresponding components added to this parent Component will use the component identifiers as the property expression.

IDetachable

In order to keep domain objects around, you’re either going to need a lot of memory / disk space, or devise a method to minimize what gets serialized in session. The detachable design helps you do this with minimal effort. Simply store as little as needed to reconstruct the domain object, and within the detach method that your Model overrides, null out the rest.

LoadableDetachableModel

In order to make things easier, LoadableDetachableModel implements a very common use case for detachable models. It gives you the ability to override a few constructors and a load method, and provides automatic reattach and detach within Wicket’s lifecycle. Let’s look at an example:

19
1
​
2
public class LoadableRefcardModel extends LoadableDetachableModel
3
{
4
  private Long id;
5
  public LoadableRefcardModel(Refcard refcard) {
6
    super(refcard);
7
    id = refcard.getId();
8
  }
9
  public LoadableRefcardModel(Long id) {
10
    super();
11
      this.id = id;
12
  }
13
  protected Object load() {
14
      if(id == null) return new Refcard();
15
      RefcardDao dao = ...
16
      return dao.get(id);
17
    }
18
}
19
​

Here we have two constructors, each grabbing the identifier and storing it with the Model. We also override the load method so that we can either return a newly created Object, or use an access object to return the Object associated with the Model’s stored identifier. LoadableDetachableModel handles the process of attaching and detaching the Object properly giving us as little overhead as possible.

Section 5

Components

In Wicket, Components display data and can react to events from the end user. In terms of the Model-View-Controller pattern, a Component is the View and the Controller. The following three distinct items make up every Wicket Component in some way:

  • Java Class implementation – defines the behavior and responsibilities
  • HTML Markup – defines the Components using their identifiers within view markup to determine where it shows to the end user
  • The Model – provides data to the Component

Now that we have an idea about what makes up a Component, let’s look at a few of the building blocks that make up the majority of our Pages. Forms and their Components are so important they have their own section.

Label

When developing your application, if you’d like to show text on the frontend chances are pretty good that you’ll be using the Label Component. A Label contains a Model object which it will convert to a String for display on the frontend.

5
1
​
2
<span wicket:id=”message”>[message]</span>
3
...
4
add(new Label(“message”, “Hello, World!”));
5
​

The first portion is an HTML template, which gives a component identifier of “message” which must be matched in the Java code. The Java code passes the component identifier as the first parameter.

Link

Below is a list of the different types of links, bookmarkable and non-bookmarkable, and how they are used to navigate from page-to-page.

Name Description
Link
7
1
​
2
If linking to another Page, it is best to use a Link in most instances:
3
add(new Link(“myLink”) {
4
    public void onClick() {
5
      setResponsePage(MyNewPage.class);
6
  }
7
}


BookmarkablePageLink A Bookmarkable page gives you a human readable URL that can be linked to directly from outside of the application. The default look of this URL can be overridden as we’ll see in the next section. add(new BookmarkablePageLink(“myLink”, MyNewPage.class);
ExternalLink If linking to an external website that is not within your application, here’s the Link component you’ll need and an example: add(new ExternalLink(“myLink”, http://www. mysticcoders.com, “Mystic”);

Repeaters

Due to the lack of any executable code inside of Wicket’s HTML templates, the method of showing lists may seem a little counterintuitive at first. One of the simplest methods for showing a list of data is the RepeatingView. Here’s an example of how to use it:

11
1
​
2
<ul>
3
    <li wicket:id=”list”></li>
4
</ul>
5
...
6
RepeatingView list = new RepeatingView(“list”);
7
add(list);
8
for(int i = 1; i <= 10; i++) {
9
    list.add(new Label(list.newChildId(), “Item “ + i));
10
}
11
​

This will simply print out a list from 1 to 10 into HTML. RepeatingView provides a method .newChildId() which should be used to ensure the Component identifier is unique. As your needs get more complex, this method quickly turns stale as there is a lot of setup that has to be done. Using a ListView is a great approach for managing possibly complex markup and business logic, and is more akin to other ways we’re asked to interact with Apache Wicket:

16
1
​
2
<ul>
3
   <li wicket:id=”list”><span wicket:id=”description”>[descripti
4
on]</span></li>
5
</ul>
6
...
7
ListView list = new ListView(“list”, Arrays.asList(“1”, “2”, “3”,
8
“4”, “5”, “6”, “7”, “8”, “9”, “10”) {
9
   @Override
10
   protected void populateItem(ListItem item) {
11
      String text = (String)item.getModelObject();
12
      item.add(new Label(“description”, text));
13
   }
14
};
15
add(list);
16
​

This method, while it looks more complex, allows us a lot more flexibility in building our lists to show to the user. The two list approaches described above each suffer from some drawbacks, one of which is that the entirety of the list must be held in memory. This doesn’t work well for large data sets, so if you need finer grain control on how much data is kept in memory, paging, etc., DataTable or DataView is something to look into.

Custom

The beauty of Wicket is that reuse is as simple as putting together a Panel of Components and adding it to any number of pages – this could be a login module, a cart, or whatever you think needs to be reused. For more great examples of reusable components check out the wicket-extensions (http://cwiki.apache.org/Wicket/wicket-extensions.html) and wicket-stuff (http:..wicketstuff.org/projects).

Hot Tip

Since Wicket always needs a tag to bind to, even for a label, a <span> tag is sometimes easier to place into your markup; however, this can throw your CSS design off. .setRenderBodyOnly(true) can be used so the span never shows on the frontend but be careful using this with any AJAX enabled components, since it requires the tag to stick around.
Section 6

Page and Navigation

A Wicket Page is a component that allows you to group components together that make up your view. All Components will be related in a tree hierarchy to your page, and if the page is bookmarkable you can navigate directly to it. Tocreate a new page, simply extend WebPage and start adding components.

Most webapps will share common areas that you don’t want to duplicate on every page -- this is where markup inheritance comes into play. Because every page is just a component, you can extend from a base page and inherit things like header, navigation, footer, whatever fits your requirements. Here’s an example:

8
1
​
2
public class BasePage extends WebPage {
3
   ... header, footer, navigation, etc ...
4
}
5
public class HomePage extends BasePage {
6
... everything else, the content of your pages...
7
}
8
​

Everything is done similarly to how you would do it in Java, without the need for messy configuration files. If we need to offer up pages that can be referenced and copied, we’re going to need to utilize bookmarkable pages. The default Wicket implementation of a BookmarkablePage is not exactly easy to memorize, so in your custom Application class you can define several mount points for your pages:

8
1
​
2
// when a user goes to /about they will get directly to this page
3
mountBookmarkablePage(“/about”, AboutPage.class);// this mount makes page available at /blog/param0/param1/param2
4
and fills PageParameters with 0-indexed numbers as the key
5
mount(new IndexedParamUrlCodingStrategy(“/blog”, BlogPage.class);// this mount makes page available at /blog?paramKey=paramValue&pa
6
ramKey2=paramValue2
7
mount(new QueryStringUrlCodingStrategy(“/blog”, BlogPage.class);
8
​

In your code, you’ll need several ways of navigating to pages, including within Link implementations, in Form onSubmits, and for an innumerable number of reasons. Here are a few of the more useful:

10
1
​
2
// Redirect to MyPage.class
3
setResponsePage(MyPage.class);// Useful to immediately interrupt request processing to perform a
4
redirect
5
throw new RestartResponseException(MyPage.class);// Redirect to an interim page such as a login page, keep the URL
6
in memory so page can call continueToOriginalDestination()
7
redirectToInterceptPage(LoginPage.class);// Useful to immediately interrupt request processing to perform a
8
redirectToInterceptPage call
9
throw new RestartResponseAtInterceptPageException(MyPage.class);
10
​
Section 7

Markup

Apache Wicket does require adding some attributes and tags to otherwise pristine X/HTML pages to achieve binding with Component code. The following table illustrates the attributes available to use in your X/HTML templates, the most important and often used being wicket:id.

Attribute Name Description
wicket:id Used on any X/HTML element you want to bind a compoent to
wicket:message Used on any tag we want to fill an attribute with a resource bundle value. To use, prefix with te [attributename]:[resource name]

The following table lists out all of the most commonly used tags in X/HTML templates with Wicket.

Tag Name Description
wicket:panel
12
1
​
2
This tag is used in your template to define the area associatedf with
3
the component. Anything outside of this tag’s hierarchy will be
4
ignored. It is sometimes useful to wrap each of your templates with
5
html and body tags like so:
6
<html xmlns:wicket=”http://wicket.apache.org”>
7
<body>
8
<wicket:panel> ... </wicket:panel>
9
</body>
10
</html>
11
In this example, you can avoid errors showing in your IDE, and it
12
won’t affect the resulting HTML.


wicket:child Used in conjunction with markup inheritance. The subclassing Page will replace the tag with the output of its component
wicket:extend Defining a page that inherits from a parent Page requires a mirroring of the relationship in your X/HTML template. As with wicket:panel, everything outside of the tag’s hierarchy will be ignored, and the component’s result will end up in the wrapping template
wicket:link
7
1
​
2
Using this tag enables autolinking to another page without having
3
to add BookmarkablePageLink’s to the component hierarchy as this
4
is done automatically for you. To link to the homepage from one of
5
its subpages:
6
<wicket:link><a href=”Homepage.html”>Homepage</
7
a></wicket:link></td>


wicket:head Adding this to the root-level hierarchy of the template will give you access to inject code into the X/HTML <head></head> section.
wicket:message This tag will look for the given key in the resource bundle component hierarchy and replace the tag with the String retrieved from that bundle property. To pull the resource property page.label: <wicket:message key=”page.label”>[page label]</ wicket:message>
wicket:remove The entire contents of this tag will be removed upon running this code in the container. Its use is to ensure that the template can show design intentions such as repeated content without interfering with the resulting markup.
wicket:fragment A fragment is an inline Panel. Using a Panel requires a separate markup file, and with a fragment this block can be contained within the parent component.
wicket:enclosure A convenience tag added in 1.3 that defines a block of code surrounding your component which derives its entire visibility from the enclosing component. This is useful in situations when showing multiple fields some of which may be empty or null where you don’t want to add WebMarkupContainers to every field just to mimic this behavior. For example if we were printing out phone and fax: <wicket:enclosure> <tr><td class=”label”>Fax:</td><td><span wicket:id=”fax”>[fax number]</span></td></tr> </wicket:enclosure> ... add(new Label(“fax”) { public boolean isVisible() { return getModelObjectAsString()!=null; } } );
wicket:container
11
1
​
2
This tag is useful when you don’t want to render any tags into the
3
markup because it may cause invalid markup. Consider the following:
4
<table>
5
  <wicket:container wicket:id=”repeater”>
6
    <tr><td>1</td></tr>
7
    <tr><td>2</td></tr>
8
  </wicket:container>
9
</table>
10
In this instance, if we were to add any code in between the table and
11
tr tags, it would be invalid. Wicket:container fixes that


.
Section 8

Form

A Form in Wicket is a component that takes user input and processes it upon submission. This component is a logical holder of one or more input fields that get processed together. The Form component, like all others, must be bound to an HTML equivalent, in this case the <form> tag.

10
1
​
2
<form wicket:id=”form”>
3
  Name: <input type=”text” wicket:id=”name” />
4
  <input type=”submit” value=”Send” />
5
</form>
6
...
7
Form form = new Form(“form”) {
8
   @Override
9
     protected void onSubmit() {
10
​
7
1
​
2
  System.out.println(“form submit”);
3
   }
4
};
5
add(form);
6
form.add(new TextField(“name”, new Model(“”));
7
​

Form input controls can each have their own Models attached to them, or can inherit from their parent, the Form. This is usually a good place to use CompoundPropertyModel as it gets rid of a lot of duplicate code. As you can see, each input component should be added to the Form element.

Wicket uses a POST to submit your form, which can be changed by overriding the Form’s getMethod and returning Form.METHOD_GET. Wicket also uses a redirect to buffer implementation details of form posts which gets around the form repost popup. The following behavior settings can be changed:

Name Setting Description
No redirect IRequestCycleSettings.ONE_PASS_RENDER Renders the response directly
Redirect to buffer IRequestCycleSettings.REDIRECT_BUFFER Renders the response directly to a buffer, redirects the browser and prevents reposting the form
Redirect to render IRequestCycleSettings. REDIRECT_TO_RENDER Redirects the browser directly; renders in a separate request

Components of a Form

The following table lists all the different form components available, and how to use them with Models.

Name Example
TextField
5
1
​
2
<input type=”text” wicket:id=”firstName” />
3
...
4
add(new TextField(“firstName”, new
5
PropertyModel(person, “firstName”));


TextArea
5
1
​
2
<textarea wicket:id=”comment”></textarea>
3
...
4
add(new TextArea(“comment”, new
5
PropertyModel(feedback, “comment”));


Button
14
1
​
2
<form wicket:id=”form”>
3
   <input type=”submit” value=”Submit”
4
wicket:id=”submit” />
5
</form>
6
...
7
Form form = new Form(“form”) {
8
   @Override
9
   protected void onSubmit() {
10
      System.out.println(“onSubmit called”);
11
   }
12
};
13
add(form);
14
form.add(new Button(“submit”));


CheckBoxMultipleChoice
9
1
​
2
<span wicket:id=”operatingSystems”>
3
   <input type=”checkbox” /> Windows   <input type=”checkbox” /> OS/2 Warp</span>
4
...
5
add(new CheckBoxMultipleChoice(“operat
6
ingSystems”, new PropertyModel(system,
7
“operatingSystems”), Arrays.asList(“Windows”,
8
“OS X”, “Linux”, “Solaris”, “HP/UX”,
9
“DOS”)));


DropDownChoice
8
1
​
2
<select wicket:id=”states”>
3
   <option>[state]</option>
4
</select>
5
...
6
add(new DropDownChoice(“states”, new
7
PropertyModel(address, “state”),
8
listOfStates));


PasswordTextField
6
1
​
2
<input type=”password” wicket:id=”password”
3
/>
4
...
5
add(new PasswordTextField(“password”, new
6
PropertyModel(user, “password”));


RadioChoice
9
1
​
2
<span wicket:id=”gender”>
3
  <input type=”radio” /> Male<br />
4
  <input type=”radio” /> Female</br />
5
</span>
6
...
7
add(new RadioChoice(“sex”, new
8
PropertyModel(person, “gender”), Arrays.
9
asList(“Male”, “Female”));


SubmitLink
14
1
​
2
<form wicket:id=”form”>
3
   <a href=”#”
4
wicket:id=”submitLink”>Submit</a>
5
</form>
6
...
7
form.add(new SubmitLink(“submitLink”) {
8
  @Override
9
  public void onSubmit() {
10
System.out.println(“submitLink
11
called”);
12
  }
13
});</td>
14
  </tr>


Validation

When dealing with user input, we need to validate it against what we’re expecting, and guide the user in the right direction if they stray. Any user input is processed through this flow:

  • Check that the required input is supplied
  • Convert input values from String to the expected type
  • Validate input using registered validators
  • Push converted and validated input to models
  • Call onSubmit or onError depending on the result

Wicket provides the following set of validators:

Resource Key Example
Required textField.setRequired(true)
RangeValidator.range numField.add(RangeValidator.range(0,10))
MinimumValidator.minimum numField.add(MinimumValidator.minimum(0))
MaximumValidator.maximum numField.add(MaximumValidator.maximum(0))
StringValidator.exact textField.add(StringValidator.exact(8))
StringValidator.range textField.add(StringValidator.range(6,18))
StringValidator.maximum textField.add(StringValidator.maximum(8))
StringValidator.minimum textField.add(StringValidator.minimum(2))
DateValidator.range dateField.add(DateValidator.range(startDate, endDate))
DateValidator.minimum dateField.add(DateValidator.minimum(minDate))
DateValidator.maximum dateField.add(DateValidator.maximum(maxDate))
CreditCardValidator ccField.add(new CreditCardValidator())
PatternValidator textFIeld.add(new PatternValidator(“\d+”)
EmailAddressValidator emailField.add(EmailAddressValidator.getInstance())
UrlValidator urlField.add(new UrlValidator())
EqualInputValidator add(new EqualInputValidator(formComp1,formComp2))
EqualPasswordInputValidator Add(new EqualPasswordInputValidator(passFld1, passFld2))

More than one validator can be added to a component if needed. For instance, if you have a password that needs to be within the range of 6 – 20 characters, must be alphanumeric and is required, simply chain the needed validators above to your component. If the validators listed above don’t fit your needs, Wicket lets you create your own and apply them to your components.

23
1
​
2
public class PostalCodeValidator extends AbstractValidator {
3
  public PostalCodeValidator() {
4
  }
5
  @Override
6
  protected void onValidate(IValidatable validatable) {
7
    String value = (String)validatable.getValue();
8
    if(!postalCodeService.isValid(value)) {
9
      error(validatable);
10
    }
11
  }
12
  @Override
13
  protected String resourceKey() {
14
    return “PostalCodeValidator”;
15
  }
16
  @Override
17
  protected Map variablesMap(IValidatable validatable) {
18
    Map map = super.variablesMap(validatable);
19
    map.put(“postalCode”, n);
20
    return map;
21
  }
22
}
23
​

When Wicket has completed processing all input it will either pass control to the Form’s onSubmit, or the Form’s onError..If you don’t choose to override onError, you’ll need a way to customize the error messages that show up.

Feedback Messages

Apache Wicket offers a facility to send back messages for failed validations or flash messages to provide notification of status after submitting a form or performing some action. Wicket’s validators come with a default set of feedback messages in a variety of languages, which you can override in your own properties files. Here’s the order Wicket uses to grab messages out of resource bundles:

Location Order Description Example
Page class 1 Messages Specific to a page Index.properties Index_es.properties
Component class 2 Messages specific to a component AddressPanel_es.properties CheckOutForm.properties
Custom Application class 3 Default application-wide message bundle
7
1
​
2
RefcardApplication_es_
3
MX.properties
4
RefcardApplication_
5
es.properties
6
RefcardApplication.
7
properties


During a Form submission, if you’d like to pass back messages to the end user, Wicket has a message queue that you can access with any component:

5
1
​
2
info(“Info message”);
3
warn(“Warn message”);
4
error(“Error message”);
5
​

With that added to the queue, the most basic method of showing these to users is to use the FeedbackPanel component which you can add to your Page as follows:

5
1
​
2
<div wicket:id=”feedback”></div>
3
…
4
add(new FeedbackPanel(“feedback”));
5
​

When you’d like to get them back out again, it will give you an Iterator to cycle through on the subsequent page:

3
1
​
2
getSession().getFeedbackMessages().iterator();
3
​
Section 9

Internationalization

Earlier sections touched on the order of resource bundles importance from the Page down to Wicket’s default application. Apache Wicket uses the same resource bundles standard in the Java platform, including the naming convention, properties file or XML file.

Using ResourceBundles, you can pull out messages in your markup using <wicket:message>, or use a ResourceModel with the component to pull out the localized text.

Another available option is to directly localize the filename of the markup files, i.e. HomePage_es_MX.html, HomePage.html. Your default locale will be used for HomePage.html, and if you were from Mexico, Wicket would dutifully grab HomePage_es_ MX.html.

Hot Tip

Wicket’s Label component overrides the getModelObjectAsString of Component to offer you Localaware String’s output to the client, so you don’t have to create your own custom converter.

Resources
Wicket 1.3 Homepage http://wicket.apache.org/
Component Reference http://wicketstuff.org/wicket13/compref/
Wicket Wiki http://cwiki.apache.org/WICKET/
Wicket by Example http://wicketbyexample.com/

Recommended Book

Wicket in action

Wicket in Action is an authoritative, comprehensive guide for Java developers building Wicketbased Web applications. This book starts with an introduction to Wicket’s structure and components, and moves quickly into examples of Wicket at work. Written by two of the project’s earliest and most authoritative experts, this book shows you both the “how-to” and the “why” of Wicket. As you move through the book, you’ll learn to use and customize Wicket components, how to interact with other technologies like Spring and Hibernate, and how to build rich, Ajax-driven features into your applications.


BUY NOW

books.dzone.com/books/wicket-action

Like This Refcard? Read More From DZone

related article thumbnail

DZone Article

WebSockets With Wicket Tutorial
related article thumbnail

DZone Article

Enhance Wicket With Spring Boot
related article thumbnail

DZone Article

Working with REST in Wicket
related article thumbnail

DZone Article

Mastering Advanced Traffic Management in Multi-Cloud Kubernetes: Scaling With Multiple Istio Ingress Gateways
related refcard thumbnail

Free DZone Refcard

Java Application Containerization and Deployment
related refcard thumbnail

Free DZone Refcard

Introduction to Cloud-Native Java
related refcard thumbnail

Free DZone Refcard

Java 15
related refcard thumbnail

Free DZone Refcard

Java 14

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: