Good you found that you needed on your own ( :-) ) and additionally now
you know why it works as it does! My point is: sometimes there is no
better documentation that the source code itself: documentation could
be out-dated but the code will never be...
Best,
Ernesto
Eyal Golan wrote:
> A small addition, if anyone encounters this situation.
> After trying the new Model[]{"bla"}, it still didn't work for me.
> Looking at the code (Ernesto ;) ), I saw in
> PropertyVariableInterpolator.interpolate(...) that it is looking for a "${"
> mark.
> So in my properties file I had to change to be:
> Reports.ReportTitle.SuspectedConnectionsUserRes = Suspected User-Resource
> Connections by ${0} Pattern Report
>
> (The $ was missing before).
>
>
> Eyal Golan
> [EMAIL PROTECTED]
>
> Visit: http://jvdrums.sourceforge.net/
> LinkedIn: http://www.linkedin.com/in/egolan74
>
> P Save a tree. Please don't print this e-mail unless it's really necessary
>
>
> On Tue, Nov 18, 2008 at 1:00 PM, Ernesto Reinaldo Barreiro <
> [EMAIL PROTECTED]> wrote:
>
>
>> Hi Eyal,
>>
>> If you open the Component class you will see a method:
>>
>> public String getString(final String key, final Component component, final
>> IModel<?> model,
>> final String defaultValue) throws MissingResourceException {
>> ....
>> }
>>
>> which finds a localizer... an Localizer after locating the key calls to :
>>
>> public String substitutePropertyExpressions(final Component component,
>> final
>> String string,
>> final IModel<?> model)
>> {
>> if ((string != null) && (model != null))
>> {
>> return PropertyVariableInterpolator.interpolate(string, model.getObject());
>> }
>> return string;
>> }
>>
>> if you look into the code of PropertyVariableInterpolator you will see it
>> delegates to PropertyResolver for variable sustitution. So, I would guess
>> something like:
>>
>>
>> getString("Reports.ReportTitle.SuspectedConnectionsUserRes", new
>> Model<Object>(new Object[]{"bla"});
>>
>> will produce:
>>
>> Suspected User-Resource Connections by bla Pattern Report
>>
>> You could also use:
>>
>> 1- Suspected User-Resource
>> Connections by {bla} Pattern Report
>> 2- A bean class
>>
>> class MyBean {
>> String bla = "bla";
>> }
>>
>> 3- and getString("Reports.ReportTitle.SuspectedConnectionsUserRes", new
>> Model<MyBean>(new MyBean());
>>
>> with the same result. Don't be afraid of looking into Wicket''s source
>> code;-)
>>
>> A quick search in google also shows me the following link
>>
>>
>> http://day-to-day-stuff.blogspot.com/2008/05/wicket-internationalization.html
>>
>> Best,
>>
>> Ernesto
>>
>> On Tue, Nov 18, 2008 at 11:21 AM, Eyal Golan <[EMAIL PROTECTED]> wrote:
>>
>>
>>> Hi,
>>> I have a key in the property file:
>>> Reports.ReportTitle.SuspectedConnectionsUserRes = Suspected User-Resource
>>> Connections by {0} Pattern Report
>>>
>>> I want to use
>>>
>> getString("Reports.ReportTitle.SuspectedConnectionsUserRes",
>>
>>> SOMETHING);
>>> to get the value with the {0} substituted. I'm not sure how to do this.
>>>
>>> Please advise,
>>>
>>> thanks
>>>
>>>
>>> Eyal Golan
>>> [EMAIL PROTECTED]
>>>
>>> Visit: http://jvdrums.sourceforge.net/
>>> LinkedIn: http://www.linkedin.com/in/egolan74
>>>
>>> P Save a tree. Please don't print this e-mail unless it's really
>>>
>> necessary
>>
>
>