Example usage for com.google.gwt.user.client.ui CheckBox getFormValue

List of usage examples for com.google.gwt.user.client.ui CheckBox getFormValue

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui CheckBox getFormValue.

Prototype

public String getFormValue() 

Source Link

Document

Returns the value property of the input element that backs this widget.

Usage

From source file:org.daxplore.presenter.client.ui.PerspectiveCheckboxPanel.java

License:Open Source License

/**
 * Get a list of the indexes of the selected perspective options.
 * // w  w  w .  jav  a  2  s. co  m
 * @return the selected option indexes
 */
public List<Integer> getPerspectiveOptions() {
    List<Integer> altList = new LinkedList<Integer>();
    for (CheckBox c : checkboxList) {
        if (c.getValue()) {
            try {
                altList.add(Integer.parseInt(c.getFormValue()));
            } catch (NumberFormatException e) {
                e.printStackTrace();
            }
        }
    }

    return altList;
}

From source file:org.opennms.features.poller.remote.gwt.client.DefaultApplicationView.java

License:Open Source License

@Override
public Set<Status> getSelectedStatuses() {

    Set<Status> statuses = new HashSet<Status>();
    for (final Widget w : getStatusesPanel()) {
        if (w instanceof CheckBox) {
            final CheckBox cb = (CheckBox) w;
            if (cb.getValue()) {
                statuses.add(Status.valueOf(cb.getFormValue()));
            }// w ww . j  a v  a 2s  .c  o  m
        }
    }
    return statuses;
}

From source file:uk.ac.ncl.openlab.intake24.client.survey.scheme.MultipleChoiceCheckboxQuestion.java

@Override
public SimpleSurveyStageInterface getInterface(final Callback1<Survey> onComplete,
        Callback2<Survey, Boolean> onIntermediateStateChange) {
    final FlowPanel content = new FlowPanel();
    content.addStyleName("intake24-multiple-choice-question");
    content.addStyleName("intake24-survey-content-container");

    content.add(WidgetFactory.createPromptPanel(questionText));

    FlowPanel checkboxesDiv = new FlowPanel();
    checkboxesDiv.addStyleName("scran24-ready-meals-checkboxes-block");

    final ArrayList<CheckBox> checkBoxes = new ArrayList<CheckBox>();

    for (String option : options) {
        FlowPanel rowDiv = new FlowPanel();
        CheckBox checkBox = new CheckBox(SafeHtmlUtils.htmlEscape(option));
        checkBox.setFormValue(option);//from   w  w w .  java 2 s  . c o m
        checkBox.addStyleName("scran24-ready-meals-checkbox");
        checkBoxes.add(checkBox);
        rowDiv.add(checkBox);
        checkboxesDiv.add(rowDiv);
    }

    if (!otherOptionName.isEmpty()) {
        FlowPanel otherPanel = new FlowPanel();
        otherOption = new CheckBox(otherOptionName.getOrDie() + ": ");
        otherPanel.add(otherOption);
        otherBox = new TextBox();
        otherPanel.add(otherBox);
        checkboxesDiv.add(otherPanel);

        otherBox.addFocusHandler(new FocusHandler() {
            @Override
            public void onFocus(FocusEvent event) {
                otherOption.setValue(true);
            }
        });
    }

    content.add(checkboxesDiv);

    Button accept = WidgetFactory.createGreenButton(acceptText, "multipleChoiceCheckboxContinueButton",
            new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {

                    StringBuilder value = new StringBuilder();
                    boolean first = true;

                    for (CheckBox checkBox : checkBoxes)
                        if (checkBox.getValue()) {
                            if (first)
                                first = false;
                            else
                                value.append(", ");

                            value.append(checkBox.getFormValue());
                        }

                    if (!otherOptionName.isEmpty()) {
                        if (otherOption.getValue()) {
                            if (!first)
                                value.append(", ");
                            value.append(otherBox.getText());
                        }
                    }

                    onComplete.call(state.withData(dataField, value.toString()));
                }
            });

    content.add(checkboxesDiv);
    content.add(accept);

    return new SimpleSurveyStageInterface(content, MultipleChoiceCheckboxQuestion.class.getSimpleName());
}