Wicket has a flexible internationalisation system that supports parameterising UI messages in many ways. There are examples e.g. in StringResourceModel javadocs, such as thi
I think the most consistent WICKETY way could be accomplished by improving Jonik's answer with MessageFormat:
.properties:
msg=Saving record {0} with value {1}
.java:
add(new Label("label", MessageFormat.format(getString("msg"),obj1,obj2)));
//or
info(MessageFormat.format(getString("msg"),obj1,obj2));
Why I like it:
StringResourceModel
.Notes:
if you want to use Models you simply need to create a simple model that override toString
function of the model like this:
abstract class MyModel extends AbstractReadOnlyModel{
@Override
public String toString()
{
if(getObject()==null)return "";
return getObject().toString();
}
}
and pass it as MessageFormat
argument.
I don't know why Wicket does not support Model
in feedback message. but if it was supported there was no reason to use these solutions and you could use StringResourceModel
everywhere.