Hi,

You can use: public final String getString(final String key, final
IModel<?> model) (
https://github.com/apache/wicket/blob/46713eef353c31372482e990ddcffe7a5ffb1bf1/wicket-core/src/main/java/org/apache/wicket/Component.java
)
The IModel parameter may be a POJO or a Map. Any placeholder like
${something} will be looked up as a bean property in case of POJO or a key
in case of a Map.
See PropertyResolver for more details.
The advantage here compared to your suggestion is that it uses named
parameters instead of indexed ones. Although you may use Array/List as
model object and use indexed parameters if you try harder.

On Wed, Apr 17, 2019 at 2:27 PM Tobias Gierke <[email protected]>
wrote:

> Hi,
>
> Is there any shorter way (shorter as in 'less characters to type') to do
> this ?
>
>
> feedback.info(MessageFormat.format(getString("feedback.info.reportDeleted"),
>
> toDelete.getReportName()));
>
> I know about StringResourceModel but
>
>       feedback.info(new
> StringResourceModel("feedback.info.reportDeleted").setParameters(
> toDelete.getReportName() ).getObject());
>
> is not exactly shorter :/
>
> It would be nice to have something like the following method on both
> Component and Localizer:
>
>      /**
> * Returns a localized string while applying <code>MessageFormat</code>
> placeholder substitution.
> *
> * The placeholder syntax is the one supported by {@link
> java.text.MessageFormat}.
> *
> * @param key Key of string resource in property file
> * @param parameters Optional parameters for placeholder substitution
> * @return The String
> * @see java.text.MessageFormat
> */
> public String getString(final String key,Object... parameters);
>
>
> Cheers,
> Tobias
>
> P.S. We're on Wicket 8 btw
>
>
>

Reply via email to