You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by extraquoo <ex...@gmail.com> on 2017/12/18 21:29:45 UTC
i18n of ButtonElement for YES/NO button text
Hi,
I am facing an i18n for a yes/no radio button listener in a Border class
when doing locale switch.
here is some piece of orginal codes
// Lets other elements register yes/no selections listeners
listeners = new ArrayList<IYesNoChangeListener>();
// The button elements for yes & no are constructed and added here
ArrayList<ButtonElement<YesNo>> buttonList = new
ArrayList<ButtonElement<YesNo>>();
buttonList.add(yes = new ButtonElement<YesNo>(
new Model<YesNo>(YesNo.Y), new Model<String>("Yes")));
buttonList.add(yes = new ButtonElement<YesNo>(
new Model<YesNo>(YesNo.N), new Model<String>("No")));
yesNoGroup = new ButtonRadioSet<YesNo>("yesNoGroup",
Model.ofList(buttonList), questionAnswer);
in the corresponding html,
<body>
<wicket:border>
* <label wicket:id="question">Question
text</label>*
<div wicket:id="bodyWrapper">
<wicket:body />
</div>
</wicket:border>
</body>
-------------------------------------
I am trying to use GetString() method to replace the "YES","NO" in model
attribute and create key-value pairs in the xml files (xxx_es.xml,
xxx_zh.xml) for different languages. However, since it is controller tier,
when I change the locale, it won't touch the class to execute border
initialization.
I find the tag <wicket:message> works perfectly for i18n. Is there any
similar way in wicket framework that can solve the i18n for
ButtonRadioSet/ButtonElement in border component?
--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: i18n of ButtonElement for YES/NO button text
Posted by extraquoo <ex...@gmail.com>.
Thank you for your answer. I am using StringResourceModel and it works
perfectly for i18n dynamically.
--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: i18n of ButtonElement for YES/NO button text
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
#getSttring() will lookup the value for the i18n bundle *once* and then the
value (a String) will be stored in the Model.
To make it dynamic you should use ResourceModel("the.i18n.key"). This model
will load the value every thing you ask it by taking into account the
content (locale, style, variation).
Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov
On Mon, Dec 18, 2017 at 11:29 PM, extraquoo <ex...@gmail.com> wrote:
> Hi,
>
> I am facing an i18n for a yes/no radio button listener in a Border class
> when doing locale switch.
>
> here is some piece of orginal codes
>
> // Lets other elements register yes/no selections listeners
> listeners = new ArrayList<IYesNoChangeListener>();
>
> // The button elements for yes & no are constructed and
> added here
> ArrayList<ButtonElement<YesNo>> buttonList = new
> ArrayList<ButtonElement<YesNo>>();
> buttonList.add(yes = new ButtonElement<YesNo>(
> new Model<YesNo>(YesNo.Y), new
> Model<String>("Yes")));
> buttonList.add(yes = new ButtonElement<YesNo>(
> new Model<YesNo>(YesNo.N), new
> Model<String>("No")));
> yesNoGroup = new ButtonRadioSet<YesNo>("yesNoGroup",
> Model.ofList(buttonList), questionAnswer);
>
>
> in the corresponding html,
>
> <body>
> <wicket:border>
>
>
>
>
> * <label
> wicket:id="question">Question
> text</label>*
>
>
>
>
> <div wicket:id="bodyWrapper">
> <wicket:body />
> </div>
> </wicket:border>
> </body>
>
> -------------------------------------
> I am trying to use GetString() method to replace the "YES","NO" in model
> attribute and create key-value pairs in the xml files (xxx_es.xml,
> xxx_zh.xml) for different languages. However, since it is controller tier,
> when I change the locale, it won't touch the class to execute border
> initialization.
> I find the tag <wicket:message> works perfectly for i18n. Is there any
> similar way in wicket framework that can solve the i18n for
> ButtonRadioSet/ButtonElement in border component?
>
>
>
> --
> Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-
> f1842947.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>