Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public class HomeView extends ViewImpl implements HomePresenter.MyView {
interface Binder extends UiBinder<Widget, HomeView> {
//First we declare our choices in an enum
private enum Choices {
VADER("Darth Vader"),
LUKE("Luke Skywalker"),
LEIA("Princess Leia"),
BOBA_FETT("Boba Fett");
public String getLiteral() {
return name;
private final String name;
Choices(String s) {
name = s;
//We decide how we want to show the different choices
private static class ChoiceRenderer extends AbstractRenderer<Choices> {
public String render(Choices choices) {
return choices != null ? choices.getLiteral() : "";
//Don’t forget that the component has to be provided
@UiField(provided = true)
MultipleChosenValueListBox<Choices> multipleValues;
HomeView(Binder uiBinder) {
//There are multiple options that you can set on GWTChosen.
//These and the construction have to be called before the call to createAndBindUi
ChosenOptions chosenOptions = new ChosenOptions();
chosenOptions.setPlaceholderText("Choose your favorite character");
multipleValues = new MultipleChosenValueListBox<>(new ChoiceRenderer(), chosenOptions);
//Acceptable and selected values are set after createAndBindUi
multipleValues.setValue(Lists.newArrayList(Choices.VADER, Choices.LEIA));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.