RE: Localization of values coming from my Model
No, javadoc is ok. You are right. My mistake, sorry. -Original Message- From: Jeffrey Schneller [mailto:jeffrey.schnel...@envisa.com] Then is the javadoc wrong? This was taken right from the javadoc? http://wicket.apache.org/docs/wicket-1.3.2/wicket/apidocs/org/apache/wic ket/model/StringResourceModel.html === Example 2 In this example, the resource key is selected based on the evaluation of a property expression: public MyPage extends WebPage { public MyPage(final PageParameters parameters) { WeatherStation ws = new WeatherStation(); add(new Label(weatherMessage, new StringResourceModel(weather.${currentStatus}, this, new Model(ws))); } } Which will call the WeatherStation.getCurrentStatus() method each time the string resource model is used and where the resource bundle for the page contains the entries: weather.sunny=Don't forget sunscreen! weather.raining=You might need an umbrella weather.snowing=Got your skis? weather.overcast=Best take a coat to be safe -Original Message- From: Bernhard Michal [mailto:michal.bernh...@tigra.cz] It doesn't seem correct... StringResourceModel expect string which is supposed to be resource key to find localization in resource bundle. I recommend you to read http://cwiki.apache.org/WICKET/localization-and-skinning-of-applications .html. -Original Message- From: Jeffrey Schneller [mailto:jeffrey.schnel...@envisa.com] I tried this and it seems to work. Is this a correct way of doing it? Label gender = new Label(gender, new StringResourceModel(${gender}, this, model)); add(gender); Obviously the StringResourceModel uses the property file for the page. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Localization of values coming from my Model
Use the StringResourceModel with properties bundle, it is very powerful because you can add dynamic data coming from the model. I've done some things like this, assuming infoModel.dateFormat() returns a formated date : new Label(tableTitle, new StringResourceModel(table.title, this, new ModelInfoModel(infoModel))); and in the properties english bundle : table.title=This table was built on $dateFormat And then you create a bundle for each locale you need. Now for something more tricky, you could solve your problem like this. Create the properties bundle : gender.female = Female gender.male = Male active.yes = Yes active.no = No and in your code : new StringResourceModel(gender_${gender}, this, getModel(; new StringResourceModel(active_${active}, this, getModel(; and in your model you simply return the key based on your condition, and it will work magically.
RE: Localization of values coming from my Model
Why don't you use special model for each component? Because this is very specific thing - CompoundPropertyModel is not supposed for this kind of model value's processing stuff. For example for activeString: add(new Label(activeString, new AbstractReadOnlyModelString() { @Override public String getObject() { return getString(yourModel.getActiveString()); } })); Anyway if you want it you can still write your own implementation of CompoundPropertyModel... -Original Message- From: Jeffrey Schneller [mailto:jeffrey.schnel...@envisa.com] Sent: Friday, October 16, 2009 4:36 PM To: users@wicket.apache.org Subject: Localization of values coming from my Model I am trying to display a page using my CompoundPropertyModel however some of the values coming from the model need to be localized before displaying to the user. This is being done inside of a wizard step. For example: My model has the following properties String gender boolean active Gender is either male or female I have a getter in my object which is getActiveString which returns Yes or No based on the T/F of the Boolean.public String getActiveString() {if (active) { return Yes;} else {return No;}} The html is: span wicket:id=gender/span span wicket:id=activeString/span The java code is: add(new Label(gender)); add(new Label(activeString)); The issue is that I need to localize the gender value. The activeString also needs to be localized. How would one do this? I need to store the values in the model as they are since it is being persisted to a db. However for certain users the data needs to be shown in their particular language when presented on the page. Any ideas? BTW... thanks you all for your previous help. I am finally in the final steps of development for my project. Thanks. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: Localization of values coming from my Model
I tried this and it seems to work. Is this a correct way of doing it? Label gender = new Label(gender, new StringResourceModel(${gender}, this, model)); add(gender); Obviously the StringResourceModel uses the property file for the page. Thanks. -Original Message- From: Bernhard Michal [mailto:michal.bernh...@tigra.cz] Sent: Friday, October 16, 2009 1:39 PM To: users@wicket.apache.org Subject: RE: Localization of values coming from my Model Why don't you use special model for each component? Because this is very specific thing - CompoundPropertyModel is not supposed for this kind of model value's processing stuff. For example for activeString: add(new Label(activeString, new AbstractReadOnlyModelString() { @Override public String getObject() { return getString(yourModel.getActiveString()); } })); Anyway if you want it you can still write your own implementation of CompoundPropertyModel... -Original Message- From: Jeffrey Schneller [mailto:jeffrey.schnel...@envisa.com] Sent: Friday, October 16, 2009 4:36 PM To: users@wicket.apache.org Subject: Localization of values coming from my Model I am trying to display a page using my CompoundPropertyModel however some of the values coming from the model need to be localized before displaying to the user. This is being done inside of a wizard step. For example: My model has the following properties String gender boolean active Gender is either male or female I have a getter in my object which is getActiveString which returns Yes or No based on the T/F of the Boolean.public String getActiveString() {if (active) { return Yes;} else {return No;}} The html is: span wicket:id=gender/span span wicket:id=activeString/span The java code is: add(new Label(gender)); add(new Label(activeString)); The issue is that I need to localize the gender value. The activeString also needs to be localized. How would one do this? I need to store the values in the model as they are since it is being persisted to a db. However for certain users the data needs to be shown in their particular language when presented on the page. Any ideas? BTW... thanks you all for your previous help. I am finally in the final steps of development for my project. Thanks. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: Localization of values coming from my Model
It doesn't seem correct... StringResourceModel expect string which is supposed to be resource key to find localization in resource bundle. I recommend you to read http://cwiki.apache.org/WICKET/localization-and-skinning-of-applications .html. -Original Message- From: Jeffrey Schneller [mailto:jeffrey.schnel...@envisa.com] I tried this and it seems to work. Is this a correct way of doing it? Label gender = new Label(gender, new StringResourceModel(${gender}, this, model)); add(gender); Obviously the StringResourceModel uses the property file for the page. -Original Message- From: Bernhard Michal [mailto:michal.bernh...@tigra.cz] Why don't you use special model for each component? Because this is very specific thing - CompoundPropertyModel is not supposed for this kind of model value's processing stuff. For example for activeString: add(new Label(activeString, new AbstractReadOnlyModelString() { @Override public String getObject() { return getString(yourModel.getActiveString()); } })); Anyway if you want it you can still write your own implementation of CompoundPropertyModel... -Original Message- From: Jeffrey Schneller [mailto:jeffrey.schnel...@envisa.com] I am trying to display a page using my CompoundPropertyModel however some of the values coming from the model need to be localized before displaying to the user. This is being done inside of a wizard step. For example: My model has the following properties String gender boolean active Gender is either male or female I have a getter in my object which is getActiveString which returns Yes or No based on the T/F of the Boolean.public String getActiveString() {if (active) { return Yes;} else {return No;}} The html is: span wicket:id=gender/span span wicket:id=activeString/span The java code is: add(new Label(gender)); add(new Label(activeString)); The issue is that I need to localize the gender value. The activeString also needs to be localized. How would one do this? I need to store the values in the model as they are since it is being persisted to a db. However for certain users the data needs to be shown in their particular language when presented on the page. Any ideas? - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: Localization of values coming from my Model
Then is the javadoc wrong? This was taken right from the javadoc? http://wicket.apache.org/docs/wicket-1.3.2/wicket/apidocs/org/apache/wic ket/model/StringResourceModel.html === Example 2 In this example, the resource key is selected based on the evaluation of a property expression: public MyPage extends WebPage { public MyPage(final PageParameters parameters) { WeatherStation ws = new WeatherStation(); add(new Label(weatherMessage, new StringResourceModel(weather.${currentStatus}, this, new Model(ws))); } } Which will call the WeatherStation.getCurrentStatus() method each time the string resource model is used and where the resource bundle for the page contains the entries: weather.sunny=Don't forget sunscreen! weather.raining=You might need an umbrella weather.snowing=Got your skis? weather.overcast=Best take a coat to be safe -Original Message- From: Bernhard Michal [mailto:michal.bernh...@tigra.cz] Sent: Friday, October 16, 2009 2:15 PM To: users@wicket.apache.org Subject: RE: Localization of values coming from my Model It doesn't seem correct... StringResourceModel expect string which is supposed to be resource key to find localization in resource bundle. I recommend you to read http://cwiki.apache.org/WICKET/localization-and-skinning-of-applications .html. -Original Message- From: Jeffrey Schneller [mailto:jeffrey.schnel...@envisa.com] I tried this and it seems to work. Is this a correct way of doing it? Label gender = new Label(gender, new StringResourceModel(${gender}, this, model)); add(gender); Obviously the StringResourceModel uses the property file for the page. -Original Message- From: Bernhard Michal [mailto:michal.bernh...@tigra.cz] Why don't you use special model for each component? Because this is very specific thing - CompoundPropertyModel is not supposed for this kind of model value's processing stuff. For example for activeString: add(new Label(activeString, new AbstractReadOnlyModelString() { @Override public String getObject() { return getString(yourModel.getActiveString()); } })); Anyway if you want it you can still write your own implementation of CompoundPropertyModel... -Original Message- From: Jeffrey Schneller [mailto:jeffrey.schnel...@envisa.com] I am trying to display a page using my CompoundPropertyModel however some of the values coming from the model need to be localized before displaying to the user. This is being done inside of a wizard step. For example: My model has the following properties String gender boolean active Gender is either male or female I have a getter in my object which is getActiveString which returns Yes or No based on the T/F of the Boolean.public String getActiveString() {if (active) { return Yes;} else {return No;}} The html is: span wicket:id=gender/span span wicket:id=activeString/span The java code is: add(new Label(gender)); add(new Label(activeString)); The issue is that I need to localize the gender value. The activeString also needs to be localized. How would one do this? I need to store the values in the model as they are since it is being persisted to a db. However for certain users the data needs to be shown in their particular language when presented on the page. Any ideas? - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org