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
When faced with something like described in the question, I would now use:
.properties:
msg=Saving record %s with value %d
Java:
add(new Label("label", String.format(getString("msg"), record, value)));
Why I like it:
String.format()
is no good. Instead, using MessageFormat is a similar approach that properly supports this.Disclaimer: this is "too obvious", but it's simpler than the other solutions (and definitely nicer than my original replaceAll()
hack). I originally sought for a "Wicket-y" way, while this kinda bypasses Wicket—then again, who cares? :-)