Wybrano datę, która jest mniejsza n" /> Wybrano datę, która jest mniejsza n" /> Wybrano datę, która jest mniejsza n"/>

How to display a simple wicket message with one simple parameter with StringResourceModel

614 Views Asked by At

I have one Wicket text property in the WicketApplicationProperties.properies

 <entry key="dataMniejszaNizMinimalna">Wybrano datę, która jest mniejsza niż minimalna akceptowalna data '${minimalnaData}'. Nie można zapisać danych."</entry>

How to substitute a parameter {minimalnaData} with a use of a class StringResourceModel. I don't want to create any models i want to just display a message with provided one attribute. The Wicket StringResourceModel is so complicated.

new StringResourceModel(resourceKey).setParameters(params)

how to provide this one parameter is a simplest way.

2

There are 2 best solutions below

2
martin-g On BEST ANSWER

The simplest way could be:

new StringResourceModel(resourceKey, this, Model.ofMap(Map.of("minimalnaData", "some value")))

The model object could be a Java Bean or a java.util.Map.

StringResourceModel also supports java.text.MessageFormat. You can use its #setParameters() method to pass an array of values for the placeholders.

0
Andrea Del Bene On

I think wicket:message should fit your need. Take a look at the wiki:

https://cwiki.apache.org/confluence/display/WICKET/Wicket%27s+XHTML+tags

You can nest components within textual content.