You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by insom <da...@gmail.com> on 2008/08/02 01:31:27 UTC

Internationalizing a DDC

I'm using John Krasnay's approach to defining display values for a
DropDownChoice, like so:

new DropDownChoice("period",
  new PropertyModel(myObject, "period"),
  periods,
  new ChoiceRenderer() {
    public String getDisplayValue(Object object) {
      int period = ((Integer) object).intValue();
      switch (period) {
        case 1: return "Day";
        case 7: return "Week";
        case 14: return "Fortnight";
        case 30: return "Month";
        case 365: return "Year";
        default: throw new RuntimeException();
      }
    }
  }
); 

My question is, how can I take advantage of Wicket's internationalization
capabilities to replace the return values with the proper values for the
locale?

-- 
View this message in context: http://www.nabble.com/Internationalizing-a-DDC-tp18784251p18784251.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: Internationalizing a DDC

Posted by Uwe Schäfer <sc...@thomas-daily.de>.
insom wrote:

> new DropDownChoice("period",
>   new PropertyModel(myObject, "period"),
>   periods,
>   new ChoiceRenderer() {
>     public String getDisplayValue(Object object) {
>       int period = ((Integer) object).intValue();
>       switch (period) {
>         case 1: return "Day";
...
>         default: throw new RuntimeException();
>       }
>     }
>   }
> ); 
> 
> My question is, how can I take advantage of Wicket's internationalization
> capabilities to replace the return values with the proper values for the
> locale?

you could just use getString:

...
case 1: return DropDownChoice.this.getString("Day");
...

-- 

THOMAS DAILY GmbH
Adlerstraße 19
79098 Freiburg
Deutschland
T  + 49 761 3 85 59 0
F  + 49 761 3 85 59 550
E  schaefer@thomas-daily.de
www.thomas-daily.de

Geschäftsführer/Managing Directors:
Wendy Thomas, Susanne Larbig
Handelsregister Freiburg i.Br., HRB 3947

Registrieren Sie sich unter http://morningnews.thomas-daily.de für die 
kostenfreien TD Morning News, eine Auswahl aktueller Themen des Tages 
morgens um 9:00 in Ihrer Mailbox.

Hinweis: Der Redaktionsschluss für unsere TD Morning News ist täglich um 
8:30 Uhr. Es werden vorrangig Informationen berücksichtigt, die nach 
16:00 Uhr des Vortages eingegangen sind. Die Email-Adresse unserer 
Redaktion lautet redaktion@thomas-daily.de.


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


SV: Internationalizing a DDC

Posted by Wilhelmsen Tor Iver <To...@arrive.no>.
> <option value="0">Day</option>
> <option value="1">Week </option>
> <option value="2">Fortnight</option>
> <option value="3">Month</option>
> <option value="4">Year</option>

If you really want to hardcode the options in the HTML like that, remember not to use DropDownChoice which will replace the markup, but make your own FormComponent subclass that preserves the entire markup. In this case, you could try

<option value="0"><wicket:message key="period.1">Day</wicket:message></option>

But the DropDownChoice + ChoiceRenderer is a better option, even if the option list is "static". In that case you just call getString("period."+idvalue) in getDisplayValue()

- Tor Iver

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


Re: Internationalizing a DDC

Posted by always_rick <sh...@hotmail.com>.
very cool, but the options' values are force to 0, 1, 2, 3, 4 ...

<option value="0">Day</option>
<option value="1">Week </option>
<option value="2">Fortnight</option>
<option value="3">Month</option>
<option value="4">Year</option>

I've tried the whole night, any help is appreciated. 
 


Sven Meier wrote:
> 
> You can do without the ChoiceRenderer if you put your terms in a 
> property file next to your panel/page:
> 
>     A.java
>         new DropDownChoice("period", ...) {
>             protected boolean localizeDisplayValues() {
>                 return true;
>             }
>         }
> 
>     A.html
>        <select wicket:id="period"/>
> 
>     A.properties
>        period.1 = Day
>        period.7 = Week
>        period.14 = Fortnight
>        period.30 = Month
>        period.365 = Year
> 
> Sven
> 
> 

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Internationalizing-a-DDC-tp1869877p2281661.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: Internationalizing a DDC

Posted by Sven Meier <sv...@meiers.net>.
You can do without the ChoiceRenderer if you put your terms in a 
property file next to your panel/page:

    A.java
        new DropDownChoice("period", ...) {
            protected boolean localizeDisplayValues() {
                return true;
            }
        }

    A.html
       <select wicket:id="period"/>

    A.properties
       period.1 = Day
       period.7 = Week
       period.14 = Fortnight
       period.30 = Month
       period.365 = Year

Sven

insom schrieb:
> I'm using John Krasnay's approach to defining display values for a
> DropDownChoice, like so:
>
> new DropDownChoice("period",
>   new PropertyModel(myObject, "period"),
>   periods,
>   new ChoiceRenderer() {
>     public String getDisplayValue(Object object) {
>       int period = ((Integer) object).intValue();
>       switch (period) {
>         case 1: return "Day";
>         case 7: return "Week";
>         case 14: return "Fortnight";
>         case 30: return "Month";
>         case 365: return "Year";
>         default: throw new RuntimeException();
>       }
>     }
>   }
> ); 
>
> My question is, how can I take advantage of Wicket's internationalization
> capabilities to replace the return values with the proper values for the
> locale?
>
>   


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