Hi,

On Tue, Jul 14, 2020 at 10:10 AM Alberto <abros...@inogs.it> wrote:

>
> Hello,
>
> I have a StringResourceModel in a parent abstract class of all pages.
>
> IModel<String> titleModel = new StringResourceModel("contentTitle",
> getModel());
>
> where "contentTitle" is a property specified for every child page in
> specific
> property files and getModel() returns a chain of a CompoundPropertyModel
> and a
> LoadableDetachableModel.
>
> If I simple use it, it works:
>
> add(new Label("pageTitle", titleModel));
>
>
> But if I apply a lambda expression to it (for example):
>
> add(new Label("pageTitle", titleModel.map(String::trim)));
>
> I have an exception.:
>
> java.util.MissingResourceException: Unable to find property:
> 'contentTitle'.
> Locale: null, style: null
>
>
> Why it happens?
>

Because .map() returns a new IModel that does not
implement IComponentAssignedModel and Wicket cannot find the property in
the visible resource bundles.
I.e. your properties are in MyPage.properties and Wicket does not look into
them because the model does not know the Component it is assigned to.
If the property is in MyApplication.properties then it will work, because
this is not related to specific Component.

Please file a ticket in JIRA. I think this could be improved.


>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to