You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Patrick Davids <pa...@nubologic.com> on 2014/07/18 18:14:33 UTC
StringResourceModel with a defaultValue as model
Hi all,
is there any way to implement a StringResourceModel which allows to give
a defaultValue as model?
First I tried to override getDefaultModelAsString() of Label. (is final)
Than I tried to implement an extending
ModeledDefaultValueStringResourceModel, catching a
MissingResourceException on getObject() or load() and retrieving my own
Model<String> defaultValue, but everthing is final here, too.
So, Im not able to achieve this, right now.
I would like to do this, because I have a dynamic way of giving buttons
a label depending of my Wizard-subclass (have my own
SpecialWizardButtonBar).
And if a button label is not availabe I want to fallback somewhere, but
the default cannot be a StringResourceModel.
Can someone help? Or is this a feature request and have to open a ticket?
kind regards, nice weekend
Patrick
[SOLVED] Re: StringResourceModel with a defaultValue as model
Posted by Patrick Davids <pa...@nubologic.com>.
Yes, already implemented this way. :-)
Added a todo now, waiting for wicket7 to improve it.
Thanx for the hint anyway...
regards
Patrick
>For now you can workaround it with: add(new Label("aaaa", new
>StringResourceModel("key.${someInfoFromBean}",
>Component.this, Model.of(anyBean), new
>StringResourceModel("key.default", Component.this).*getObject()*));
Am 21.07.2014 09:43, schrieb Martin Grigorov:
> For now you can workaround it with:
> add(new Label("aaaa", new StringResourceModel("key.${someInfoFromBean}",
> Component.this, Model.of(anyBean), new
> StringResourceModel("key.default", Component.this).*getObject()*));
Re: StringResourceModel with a defaultValue as model
Posted by Martin Grigorov <mg...@apache.org>.
On Mon, Jul 21, 2014 at 10:39 AM, Patrick Davids <
patrick.davids@nubologic.com> wrote:
> Hi François,
> what I try to do is a bit different... I would like to provide a default
> per component sub-class, before wicket cascades the property files up to
> application.properties.
>
> Something like this:
> add(new Label("aaaa", new StringResourceModel("key.${someInfoFromBean}",
> Component.this, Model.of(anyBean), new
> StringResourceModel("key.default", Component.this)));
>
> Hi Martin,
> ok, this will solve my problem, next.
> > In Wicket 7 the API is changed to IModel<String> with
> > https://issues.apache.org/jira/browse/WICKET-4972
>
For now you can workaround it with:
add(new Label("aaaa", new StringResourceModel("key.${someInfoFromBean}",
Component.this, Model.of(anyBean), new
StringResourceModel("key.default", Component.this).*getObject()*));
>
>
> kind regards
> Patrick
>
> Am 18.07.2014 19:02, schrieb Francois Meillet:
> > In your Application.properties
> > you add the key key.to.be.good=theValue
> >
> > and you can use the StringResourceModel like that
> >
> > add( new Label("aaaa", new StringResourceModel("key.to.be.good",
> null)));
> >
> >
> > François Meillet
> > Formation Wicket - Développement Wicket
> >
> >
> >
> >
> >
> > Le 18 juil. 2014 à 18:14, Patrick Davids <pa...@nubologic.com>
> a écrit :
> >
> >> Hi all,
> >> is there any way to implement a StringResourceModel which allows to give
> >> a defaultValue as model?
> >>
> >> First I tried to override getDefaultModelAsString() of Label. (is final)
> >> Than I tried to implement an extending
> >> ModeledDefaultValueStringResourceModel, catching a
> >> MissingResourceException on getObject() or load() and retrieving my own
> >> Model<String> defaultValue, but everthing is final here, too.
> >>
> >> So, Im not able to achieve this, right now.
> >>
> >> I would like to do this, because I have a dynamic way of giving buttons
> >> a label depending of my Wizard-subclass (have my own
> >> SpecialWizardButtonBar).
> >>
> >> And if a button label is not availabe I want to fallback somewhere, but
> >> the default cannot be a StringResourceModel.
> >>
> >> Can someone help? Or is this a feature request and have to open a
> ticket?
> >>
> >> kind regards, nice weekend
> >> Patrick
> B�KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKCB� �
> [��X��ܚX�K K[XZ[ � \�\��][��X��ܚX�P �X��] �\ X� K�ܙ�B��܈ Y ] [ۘ[ ��[X[�
> � K[XZ[ � \�\��Z [ �X��] �\ X� K�ܙ�B�
> >
> >
>
> --
> Mit freundlichen Grüßen,
>
> Patrick Davids
>
> nuboLOGIC GmbH & Co. KG
> Kieler Str. 103-107 • 25474 Bönningstedt
>
> Tel.: +49 40 228539 732
> Email: patrick.davids@nubologic.com
>
> http://www.nubologic.com
>
> Handelsregister: HRA6819 Pi | Amtsgericht Pinneberg
>
> Geschäftsführung der Verwaltungsgesellschaft
> Daniel Fraga Zander
>
> HRB10145Pi | Amtsgericht Pinneberg
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: StringResourceModel with a defaultValue as model
Posted by Patrick Davids <pa...@nubologic.com>.
Hi François,
what I try to do is a bit different... I would like to provide a default
per component sub-class, before wicket cascades the property files up to
application.properties.
Something like this:
add(new Label("aaaa", new StringResourceModel("key.${someInfoFromBean}",
Component.this, Model.of(anyBean), new
StringResourceModel("key.default", Component.this)));
Hi Martin,
ok, this will solve my problem, next.
> In Wicket 7 the API is changed to IModel<String> with
> https://issues.apache.org/jira/browse/WICKET-4972
kind regards
Patrick
Am 18.07.2014 19:02, schrieb Francois Meillet:
> In your Application.properties
> you add the key key.to.be.good=theValue
>
> and you can use the StringResourceModel like that
>
> add( new Label("aaaa", new StringResourceModel("key.to.be.good", null)));
>
>
> François Meillet
> Formation Wicket - Développement Wicket
>
>
>
>
>
> Le 18 juil. 2014 à 18:14, Patrick Davids <pa...@nubologic.com> a écrit :
>
>> Hi all,
>> is there any way to implement a StringResourceModel which allows to give
>> a defaultValue as model?
>>
>> First I tried to override getDefaultModelAsString() of Label. (is final)
>> Than I tried to implement an extending
>> ModeledDefaultValueStringResourceModel, catching a
>> MissingResourceException on getObject() or load() and retrieving my own
>> Model<String> defaultValue, but everthing is final here, too.
>>
>> So, Im not able to achieve this, right now.
>>
>> I would like to do this, because I have a dynamic way of giving buttons
>> a label depending of my Wizard-subclass (have my own
>> SpecialWizardButtonBar).
>>
>> And if a button label is not availabe I want to fallback somewhere, but
>> the default cannot be a StringResourceModel.
>>
>> Can someone help? Or is this a feature request and have to open a ticket?
>>
>> kind regards, nice weekend
>> PatrickB�KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKCB��[��X��ܚX�KK[XZ[�\�\��][��X��ܚX�P�X��]�\X�K�ܙ�B��܈Y][ۘ[��[X[��K[XZ[�\�\��Z[�X��]�\X�K�ܙ�B�
>
>
--
Mit freundlichen Grüßen,
Patrick Davids
nuboLOGIC GmbH & Co. KG
Kieler Str. 103-107 • 25474 Bönningstedt
Tel.: +49 40 228539 732
Email: patrick.davids@nubologic.com
http://www.nubologic.com
Handelsregister: HRA6819 Pi | Amtsgericht Pinneberg
Geschäftsführung der Verwaltungsgesellschaft
Daniel Fraga Zander
HRB10145Pi | Amtsgericht Pinneberg
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: StringResourceModel with a defaultValue as model
Posted by Francois Meillet <fr...@gmail.com>.
In your Application.properties
you add the key key.to.be.good=theValue
and you can use the StringResourceModel like that
add( new Label("aaaa", new StringResourceModel("key.to.be.good", null)));
François Meillet
Formation Wicket - Développement Wicket
Le 18 juil. 2014 à 18:14, Patrick Davids <pa...@nubologic.com> a écrit :
> Hi all,
> is there any way to implement a StringResourceModel which allows to give
> a defaultValue as model?
>
> First I tried to override getDefaultModelAsString() of Label. (is final)
> Than I tried to implement an extending
> ModeledDefaultValueStringResourceModel, catching a
> MissingResourceException on getObject() or load() and retrieving my own
> Model<String> defaultValue, but everthing is final here, too.
>
> So, Im not able to achieve this, right now.
>
> I would like to do this, because I have a dynamic way of giving buttons
> a label depending of my Wizard-subclass (have my own
> SpecialWizardButtonBar).
>
> And if a button label is not availabe I want to fallback somewhere, but
> the default cannot be a StringResourceModel.
>
> Can someone help? Or is this a feature request and have to open a ticket?
>
> kind regards, nice weekend
> PatrickB�KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKCB��[��X��ܚX�KK[XZ[�\�\��][��X��ܚX�P�X��]�\X�K�ܙ�B��܈Y][ۘ[��[X[��K[XZ[�\�\��Z[�X��]�\X�K�ܙ�B�
Re: StringResourceModel with a defaultValue as model
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
There is a defaultValue already.
org.apache.wicket.model.StringResourceModel#StringResourceModel(java.lang.String,
org.apache.wicket.Component, org.apache.wicket.model.IModel<?>,
*java.lang.String*, java.lang.Object...)
In Wicket 7 the API is changed to IModel<String> with
https://issues.apache.org/jira/browse/WICKET-4972
Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov
On Fri, Jul 18, 2014 at 7:14 PM, Patrick Davids <
patrick.davids@nubologic.com> wrote:
> Hi all,
> is there any way to implement a StringResourceModel which allows to give
> a defaultValue as model?
>
> First I tried to override getDefaultModelAsString() of Label. (is final)
> Than I tried to implement an extending
> ModeledDefaultValueStringResourceModel, catching a
> MissingResourceException on getObject() or load() and retrieving my own
> Model<String> defaultValue, but everthing is final here, too.
>
> So, Im not able to achieve this, right now.
>
> I would like to do this, because I have a dynamic way of giving buttons
> a label depending of my Wizard-subclass (have my own
> SpecialWizardButtonBar).
>
> And if a button label is not availabe I want to fallback somewhere, but
> the default cannot be a StringResourceModel.
>
> Can someone help? Or is this a feature request and have to open a ticket?
>
> kind regards, nice weekend
> Patrick