Re: Usage of getString with parameters (model?)
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(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(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 >> > >
Re: Usage of getString with parameters (model?)
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(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(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 > > >
Re: Usage of getString with parameters (model?)
Nino, Ernesto, Thanks. Ernesto, I actually looked into the code that you showed. I was a bit confused and that's why I asked. I think your solution will help me. 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 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(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(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 > > >
Re: Usage of getString with parameters (model?)
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(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(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 >
Re: Usage of getString with parameters (model?)
Igor wrote something about it in a thread with validators.. But heres my cut: add(new Label("confirmation.content", new StringResourceModel( "confirmation.content", this, eventModel))); and in property file: confirmation.content=You are about to create event '${name}', in city '${location.nearestCityName}', see preview of event below, please press finish to complete. Notice that tags will be populated when confirmed. Eyal Golan 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 -- -Wicket for love Nino Martinez Wael Java Specialist @ Jayway DK http://www.jayway.dk +45 2936 7684 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Usage of getString with parameters (model?)
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