Default Behavior

Wicketopia tries to use sensible defaults wherever possible to avoid the need for customization. To display a property name, Wicketopia will capitalize it and split it based on capitalization. For example:

  • "gender" becomes "Gender"
  • "firstName" becomes "First Name"
  • "ssn" becomes "Ssn"

Custom Behavior

Of course, these rules aren't perfect. For example, "Ssn" should probably be displayed as "SSN". Wicketopia allows you to customize this behavior using annotations:

Custom SSN Label...

@DisplayName("SSN")
public String getSsn()
{
  return ssn;
}

Using Internationalization (i18n)

Thus far, we have only had the option to display one name for the property, either based on the property name itself or supplying a custom name to be used via annotations. However, sometimes we would like to be able to display property names differently depending on the locale of the user. Wicketopia relies upon Wicket's flexible i18n support for this. Wicketopia allows you to override property names by supplying an i18n message. For example, consider the "fName" property of a class named "com.myco.domain.Person":

In English (Application.properties)...

com.myco.domain.Person.fName=First Name

In Dutch (Application_nl.properties)...

com.myco.domain.Person.fName=Voornaam

Sometimes, these keys can be tough to manage, especially if there are a lot of classes with properties of the same name. You can customize the default message key by overriding the calculateDisplayNameMessageKey() method of the Wicketopia class.

Custom i18n Keys

public String calculateDisplayNameMessageKey(PropertyMetaData propertyMetaData)
{
  return propertyMetaData.getPropertyDescriptor().getName();
}

Here, we have set it up so that the keys are simply the property names themselves.