smack
smack

Reputation: 113

Cuba - Set localized caption for Button

I am trying, to set different localized messages for a button (depending on a state) in cuba. In the xml I have

<button caption="msg://contact"
        invoke="onContactBtnClick"
        width="100%"/>

Now I would like to change the caption in the onContactBtnClick-Method. But when I set the caption to "msg://hello" I do not get the localized Button, but just msg://hello.

How do I have to set this?

Thx

Upvotes: 3

Views: 130

Answers (1)

jreznot
jreznot

Reputation: 2773

If you want to obtain a localized message from a Window controller you have to use getMessage method with the message key.

button.setCaption(getMessage("hello"));

Also you can use Messages infrastructure interface:

@Inject
private Messages messages;
...
messages.getMessage(YourClass.class, "hello")

See documentation on Messages here: https://doc.cuba-platform.com/manual-6.1/messages.html

Upvotes: 3

Related Questions