You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by i ii <kh...@hotmail.com> on 2008/03/12 16:20:57 UTC

StringResourceModel labels within values

is there way to do something like:

.properties file:

some.label=Some Label
some.text=Some Text
some.key=This text will have ${some.label} and ${some.text}

Re: StringResourceModel labels within values

Posted by Igor Vaynberg <ig...@gmail.com>.
you can roll your own model...

-igor


On Wed, Mar 12, 2008 at 8:20 AM, i ii <kh...@hotmail.com> wrote:
>
>  is there way to do something like:
>
>  .properties file:
>
>  some.label=Some Label
>  some.text=Some Text
>  some.key=This text will have ${some.label} and ${some.text}
>

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


Re: Wicket Kitchen Sink Application?

Posted by Martijn Dashorst <ma...@gmail.com>.
wicket-examples, wicket-phonebook, jtrac, artifactory, jalbum(?)

Martijn

On 3/13/08, Hoover, William <wh...@nemours.org> wrote:
> Anyone know of a good kitchen sink application for Wicket (preferably one application)? We need something robust enough to test most of the Wicket features in our current environment.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.1 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.1

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


Re: StringResourceModel labels within values

Posted by Sebastiaan van Erk <se...@sebster.com>.
Sebastiaan van Erk wrote:
> How's this:
> 
> public class RecursiveStringResourceModel extends AbstractReadOnlyModel {
> 
>     private final String resourceKey;
>     
>     private final Component component;
>     
>     public RecursiveStringResourceModel(final String resourceKey, final 
> Component component) {
>         this.resourceKey = resourceKey;
>         this.component = component;
>     }
>     
>     @Override
>     public Object getObject() {
>         return new StringResourceModel(resourceKey, component, new 
> CompoundPropertyModel(new AbstractMap() {
>             @Override
>             public Object get(Object key) {
>                 return new RecursiveStringResourceModel((String) key, 
> component).getObject();
>             }
> 
>             @Override
>             public Set<java.util.Map.Entry<String, String>> entrySet() {
>                 return null;
>             }
>         })).getObject();
>     }
> 
> }
> 
> I'm sure it can be done more efficiently (i.e., less model creation), 
> but hey, it works! ;-)

For starters, it's much better to subclass LoadableDetachableModel and 
move the getOjbect() to load(). :-)

Regards,
Sebastiaan

Wicket Kitchen Sink Application?

Posted by "Hoover, William " <wh...@nemours.org>.
Anyone know of a good kitchen sink application for Wicket (preferably one application)? We need something robust enough to test most of the Wicket features in our current environment.


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


Re: StringResourceModel labels within values

Posted by Sebastiaan van Erk <se...@sebster.com>.
How's this:

public class RecursiveStringResourceModel extends AbstractReadOnlyModel {

	private final String resourceKey;
	
	private final Component component;
	
	public RecursiveStringResourceModel(final String resourceKey, final 
Component component) {
		this.resourceKey = resourceKey;
		this.component = component;
	}
	
	@Override
	public Object getObject() {
		return new StringResourceModel(resourceKey, component, new 
CompoundPropertyModel(new AbstractMap() {
			@Override
			public Object get(Object key) {
				return new RecursiveStringResourceModel((String) key, 
component).getObject();
			}

			@Override
			public Set<java.util.Map.Entry<String, String>> entrySet() {
				return null;
			}
		})).getObject();
	}

}

I'm sure it can be done more efficiently (i.e., less model creation), 
but hey, it works! ;-)

Regards,
Sebastiaan

i ii wrote:
> how will this work with example i gave? i'm not sure how to get some.label and some.text back into some.key? would i use something like 
> 
> StringResourceModel srm = new StringResourceModel("some.key", this, null);
> PropertyVariableInterpolator.interpolate("some.label", srm);
> 
> not sure that works :(
> 
>> Date: Thu, 13 Mar 2008 12:17:09 +0100
>> From: sebster@sebster.com
>> To: users@wicket.apache.org
>> Subject: Re: StringResourceModel labels within values
>>
>> At one point I wanted to do interpolation in constant strings, so I just 
>> used the property interpolator directly:
>>
>> PropertyVariableInterpolator.interpolate(value, modelObject);
>>
>> You can use that to build a model that recursively interpolates until 
>> there are no more ${...} occurrences in the value.
>>
>> Regards,
>> Sebastiaan
>>
>> i ii wrote:
>>> thank you for help! which way is better? my own component or srm model that gets from localizer?
>>>
>>>> Date: Wed, 12 Mar 2008 13:57:10 -0700
>>>> From: igor.vaynberg@gmail.com
>>>> To: users@wicket.apache.org
>>>> Subject: Re: StringResourceModel labels within values
>>>>
>>>> but will that work recusively? :)
>>>>
>>>> -igor
>>>>
>>>>
>>>> On Wed, Mar 12, 2008 at 1:44 PM, Johan Compagner <jc...@gmail.com> wrote:
>>>>> I think if you just give SRM a model that again gets the values from
>>>>>  the localizer then it should work fine.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>  On 3/12/08, i ii <kh...@hotmail.com> wrote:
>>>>>  >
>>>>>  > is there way to do something like:
>>>>>  >
>>>>>  > .properties file:
>>>>>  >
>>>>>  > some.label=Some Label
>>>>>  > some.text=Some Text
>>>>>  > some.key=This text will have ${some.label} and ${some.text}
>>>>>  >
>>>>>
>>>>>  ---------------------------------------------------------------------
>>>>>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>  For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
> 

RE: StringResourceModel labels within values

Posted by i ii <kh...@hotmail.com>.
how will this work with example i gave? i'm not sure how to get some.label and some.text back into some.key? would i use something like 

StringResourceModel srm = new StringResourceModel("some.key", this, null);
PropertyVariableInterpolator.interpolate("some.label", srm);

not sure that works :(

> Date: Thu, 13 Mar 2008 12:17:09 +0100
> From: sebster@sebster.com
> To: users@wicket.apache.org
> Subject: Re: StringResourceModel labels within values
> 
> At one point I wanted to do interpolation in constant strings, so I just 
> used the property interpolator directly:
> 
> PropertyVariableInterpolator.interpolate(value, modelObject);
> 
> You can use that to build a model that recursively interpolates until 
> there are no more ${...} occurrences in the value.
> 
> Regards,
> Sebastiaan
> 
> i ii wrote:
> > thank you for help! which way is better? my own component or srm model that gets from localizer?
> > 
> >> Date: Wed, 12 Mar 2008 13:57:10 -0700
> >> From: igor.vaynberg@gmail.com
> >> To: users@wicket.apache.org
> >> Subject: Re: StringResourceModel labels within values
> >>
> >> but will that work recusively? :)
> >>
> >> -igor
> >>
> >>
> >> On Wed, Mar 12, 2008 at 1:44 PM, Johan Compagner <jc...@gmail.com> wrote:
> >>> I think if you just give SRM a model that again gets the values from
> >>>  the localizer then it should work fine.
> >>>
> >>>
> >>>
> >>>
> >>>  On 3/12/08, i ii <kh...@hotmail.com> wrote:
> >>>  >
> >>>  > is there way to do something like:
> >>>  >
> >>>  > .properties file:
> >>>  >
> >>>  > some.label=Some Label
> >>>  > some.text=Some Text
> >>>  > some.key=This text will have ${some.label} and ${some.text}
> >>>  >
> >>>
> >>>  ---------------------------------------------------------------------
> >>>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>>  For additional commands, e-mail: users-help@wicket.apache.org
> >>>
> >>>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> > 

Re: StringResourceModel labels within values

Posted by Sebastiaan van Erk <se...@sebster.com>.
At one point I wanted to do interpolation in constant strings, so I just 
used the property interpolator directly:

PropertyVariableInterpolator.interpolate(value, modelObject);

You can use that to build a model that recursively interpolates until 
there are no more ${...} occurrences in the value.

Regards,
Sebastiaan

i ii wrote:
> thank you for help! which way is better? my own component or srm model that gets from localizer?
> 
>> Date: Wed, 12 Mar 2008 13:57:10 -0700
>> From: igor.vaynberg@gmail.com
>> To: users@wicket.apache.org
>> Subject: Re: StringResourceModel labels within values
>>
>> but will that work recusively? :)
>>
>> -igor
>>
>>
>> On Wed, Mar 12, 2008 at 1:44 PM, Johan Compagner <jc...@gmail.com> wrote:
>>> I think if you just give SRM a model that again gets the values from
>>>  the localizer then it should work fine.
>>>
>>>
>>>
>>>
>>>  On 3/12/08, i ii <kh...@hotmail.com> wrote:
>>>  >
>>>  > is there way to do something like:
>>>  >
>>>  > .properties file:
>>>  >
>>>  > some.label=Some Label
>>>  > some.text=Some Text
>>>  > some.key=This text will have ${some.label} and ${some.text}
>>>  >
>>>
>>>  ---------------------------------------------------------------------
>>>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>  For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
> 

RE: StringResourceModel labels within values

Posted by i ii <kh...@hotmail.com>.
thank you for help! which way is better? my own component or srm model that gets from localizer?

> Date: Wed, 12 Mar 2008 13:57:10 -0700
> From: igor.vaynberg@gmail.com
> To: users@wicket.apache.org
> Subject: Re: StringResourceModel labels within values
> 
> but will that work recusively? :)
> 
> -igor
> 
> 
> On Wed, Mar 12, 2008 at 1:44 PM, Johan Compagner <jc...@gmail.com> wrote:
> > I think if you just give SRM a model that again gets the values from
> >  the localizer then it should work fine.
> >
> >
> >
> >
> >  On 3/12/08, i ii <kh...@hotmail.com> wrote:
> >  >
> >  > is there way to do something like:
> >  >
> >  > .properties file:
> >  >
> >  > some.label=Some Label
> >  > some.text=Some Text
> >  > some.key=This text will have ${some.label} and ${some.text}
> >  >
> >
> >  ---------------------------------------------------------------------
> >  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >  For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 

Re: StringResourceModel labels within values

Posted by Johan Compagner <jc...@gmail.com>.
if you use again StringResourceModels in the model that you give to your
outer StringResourceModel :)

johan



On Wed, Mar 12, 2008 at 9:57 PM, Igor Vaynberg <ig...@gmail.com>
wrote:

> but will that work recusively? :)
>
> -igor
>
>
> On Wed, Mar 12, 2008 at 1:44 PM, Johan Compagner <jc...@gmail.com>
> wrote:
> > I think if you just give SRM a model that again gets the values from
> >  the localizer then it should work fine.
> >
> >
> >
> >
> >  On 3/12/08, i ii <kh...@hotmail.com> wrote:
> >  >
> >  > is there way to do something like:
> >  >
> >  > .properties file:
> >  >
> >  > some.label=Some Label
> >  > some.text=Some Text
> >  > some.key=This text will have ${some.label} and ${some.text}
> >  >
> >
>  >  ---------------------------------------------------------------------
> >  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >  For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: StringResourceModel labels within values

Posted by Igor Vaynberg <ig...@gmail.com>.
but will that work recusively? :)

-igor


On Wed, Mar 12, 2008 at 1:44 PM, Johan Compagner <jc...@gmail.com> wrote:
> I think if you just give SRM a model that again gets the values from
>  the localizer then it should work fine.
>
>
>
>
>  On 3/12/08, i ii <kh...@hotmail.com> wrote:
>  >
>  > is there way to do something like:
>  >
>  > .properties file:
>  >
>  > some.label=Some Label
>  > some.text=Some Text
>  > some.key=This text will have ${some.label} and ${some.text}
>  >
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: StringResourceModel labels within values

Posted by Johan Compagner <jc...@gmail.com>.
I think if you just give SRM a model that again gets the values from
the localizer then it should work fine.


On 3/12/08, i ii <kh...@hotmail.com> wrote:
>
> is there way to do something like:
>
> .properties file:
>
> some.label=Some Label
> some.text=Some Text
> some.key=This text will have ${some.label} and ${some.text}
>

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