Hello! I’m a junior-developer and i have some troubles with localization in add-on widget, which is called DigitalClock.
So… I need to change dynamically the locale of my application, and it must change the locale of DigitalClock widget component as well.
For example, something like this (not more than example):
package com.example.testproject;
import java.util.Locale;
import com.askvikrant.digitalclock.DigitalClock;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Button.ClickEvent;
@SuppressWarnings("serial")
public class TestprojectUI extends UI {
VerticalLayout main;
DigitalClock clock;
ComboBox languageSelector;
Button okButton;
Locale ruLocale;
Locale usLocale;
protected void init(VaadinRequest request) {
main = new VerticalLayout();
setContent(main);
main.setSizeFull();
clock = new DigitalClock();
languageSelector = new ComboBox();
usLocale = new Locale("en", "US");
ruLocale = new Locale("ru", "RU");
languageSelector.addItem(usLocale);
languageSelector.addItem(ruLocale);
languageSelector.setNullSelectionAllowed(false);
languageSelector.setValue(usLocale);
okButton = new Button("OK");
okButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
clock.setLocale((Locale) languageSelector.getValue());
}
});
main.addComponent(clock);
main.addComponent(languageSelector);
main.addComponent(okButton);
}
}
Of course it doesn’t work. I read the gwt i18n docs and changed the widgets.gwt then I made tag by BootstrapListener. It works… But I need change the locale dinamycally and i haven’t had succes in this.
Help-Help! What can you recommend?