Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

will convert the contents of the text field to and from an Integer value.

Warning
titleBoundCompoundPropertyModel has been removed in Wicket 6!

In the event that you need more flexibility or property expressions power in your compound models, you can use the BoundCompoundPropertyModel. This class provides three methods you can call on the container's model object to bind a given child Component to a specific property expression and/or type conversion:

Code Block

public Component bind(final Component component, final String propertyExpression)
public Component bind(final Component component, final Class type)
public Component bind(final Component component, final String propertyExpression, final Class type)

Wiki Markup
To see how this might be used, suppose that the {{stringProperty}} value needed to be bound to the property expression {{"person\[0\].stringProperty"}}.  In the {{FormInput}} constructor, we'd say something like this:

Code Block

super(name);
final BoundCompoundPropertyModel formModel = new BoundCompoundPropertyModel(new FormInputModel());
setModel(formModel);
add(formModel.bind(new RequiredTextField("stringProperty"), "person[0].stringProperty"));

The Form is constructed without a model. We then create the Form's model as a BoundCompoundPropertyModel, set it as the Form's model and finally use it to bind the RequiredTextField to the desired property expression.

String Resource Models

Localization of resources in Wicket is supported by the Localizer class. This provides a very convenient way to retrieve and format application and component specific resources according to the Locale that the user's Session is running under. In many cases, it will be sufficient to simply retrieve a localized String in this way, but if a formatted, localized string is desired as a model, a StringResourceModel may be used.

...