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

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

Introduction

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

Prototype

public String getFormValue() 

Source Link

Document

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

Usage

From source file:com.edgenius.wiki.gwt.client.space.SpaceLinkedBlogForm.java

License:Open Source License

public BlogMeta getSelectedBlog() {
    BlogMeta selectedBlog = null;/*from   w  w w . ja  v  a2 s.  c  om*/
    //first, try to check if user select a blog from blog list checkbox 

    if (blogMetas != null && blogMetas.size() > 0) {
        //following code looks ugly: for get linked blogMeta
        for (Iterator<Widget> iter = bloglist.iterator(); iter.hasNext();) {
            Widget widget = iter.next();
            if (widget instanceof RadioButton) {
                RadioButton radio = ((RadioButton) widget);
                if (radio.getValue()) {
                    String blogID = radio.getFormValue();
                    for (Iterator<BlogMeta> it = blogMetas.iterator(); it.hasNext();) {
                        BlogMeta meta = it.next();
                        if (StringUtil.equals(meta.getId(), blogID)) {
                            selectedBlog = meta;
                            break;
                        }
                    }
                }
            }
            if (selectedBlog != null)
                ;
            break;
        }
    }

    //if user not select from checkbox, then check if we already have a "currentBlog"
    if (selectedBlog == null) {
        selectedBlog = currentBlogMeta;
    }

    //all input(URL,user, password) will overwrite existed value, this is true if user want to update - 
    //for example, only update password then save
    //the bad is, we need do further validate in link blog to space as the inputs maybe wrong even they pick up
    //from drop list.
    if (selectedBlog != null) {
        int blogType = NumberUtil.toInt(blogs.getSelectedValue(), 0);
        if (blogType == 0 || !blogUser.isValidForSubmit() || !blogPassword.isValidForSubmit()
                || !blogUrl.isValidForSubmit()) {
            //if any input are wrong value, return null,means invalid input
            selectedBlog = null;
        } else {
            selectedBlog.setType(blogType);
            selectedBlog.setUsername(blogUser.getText());
            selectedBlog.setPassword(blogPassword.getText());
            selectedBlog.setUrl(blogUrl.getText());
        }
    }
    return selectedBlog;
}

From source file:com.jwh.gwt.fasttable.sample.client.FastTableSample.java

License:Open Source License

private void buildRowCountButtons(FlexTable flexTable) {
    flexTable.setWidget(0, 0, new Label());
    flexTable.getFlexCellFormatter().setColSpan(0, 0, 2);
    final String rows10 = "10 sample rows";
    final String rows100 = "100 sample rows";
    final String rows500 = "500 sample rows";
    final String rows1000 = "1000 sample rows";
    final String rowsToBuild = "rowsToBuild";
    final ValueChangeHandler<Boolean> handler = new ValueChangeHandler<Boolean>() {
        @Override//from   ww w.java 2s . c  o  m
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            RadioButton selected = (RadioButton) event.getSource();
            if (rows10.equals(selected.getFormValue())) {
                sampleRowCount = 10;
            } else if (rows100.equals(selected.getFormValue())) {
                sampleRowCount = 100;
            } else if (rows500.equals(selected.getFormValue())) {
                sampleRowCount = 500;
            } else {
                sampleRowCount = 1000;
            }
        }
    };
    {
        final RadioButton radio = new RadioButton(rowsToBuild);
        radio.setHTML(rows10);
        radio.setValue(false, false);
        radio.setFormValue(rows10);
        radio.addValueChangeHandler(handler);
        flexTable.setWidget(1, 0, radio);
        flexTable.getFlexCellFormatter().setColSpan(1, 0, 2);
        radio.getElement().getParentElement().addClassName(BORDER_NONE);
    }
    {
        final RadioButton radio = new RadioButton(rowsToBuild);
        radio.setHTML(rows100);
        radio.setValue(true, false);
        radio.setFormValue(rows100);
        radio.addValueChangeHandler(handler);
        flexTable.setWidget(2, 0, radio);
        flexTable.getFlexCellFormatter().setColSpan(2, 0, 2);
        radio.getElement().getParentElement().addClassName(BORDER_NONE);
    }
    {
        final RadioButton radio = new RadioButton(rowsToBuild);
        radio.setHTML(rows500);
        radio.setValue(false, false);
        radio.setFormValue(rows500);
        radio.addValueChangeHandler(handler);
        flexTable.setWidget(3, 0, radio);
        flexTable.getFlexCellFormatter().setColSpan(3, 0, 2);
        radio.getElement().getParentElement().addClassName(BORDER_NONE);
    }
    {
        final RadioButton radio = new RadioButton(rowsToBuild);
        radio.setHTML(rows1000);
        radio.setValue(false, false);
        radio.setFormValue(rows1000);
        radio.addValueChangeHandler(handler);
        flexTable.setWidget(4, 0, radio);
        flexTable.getFlexCellFormatter().setColSpan(4, 0, 2);
        radio.getElement().getParentElement().addClassName(BORDER_NONE);
    }
}

From source file:de.schott.gae.football.client.DatabasePage.java

License:Apache License

/**
 * Create page with possible solutions. async.
 * /*from w ww  . java  2  s.c o m*/
 * @param implementations
 */
private void createPage(List<TransferObject> implementations) {
    Panel root = RootPanel.get(FootballEntry.CONTENT_ID);
    root.clear();

    VerticalPanel panel = new VerticalPanel();
    Label lblHeader = new Label("Choose Database implementation");
    lblHeader.setStyleName("h1");

    // Make some radio buttons, all in one group.
    VerticalPanel radioPanel = new VerticalPanel();
    final List<RadioButton> radioButtons = new ArrayList<RadioButton>();
    for (TransferObject to : implementations) {
        RadioButton radio = new RadioButton("radiogroup", (String) to.get("name"));
        radio.setValue((Boolean) to.get("selected"));
        Integer id = (Integer) to.get("id");
        radio.setFormValue(id.toString());
        radioButtons.add(radio);
        radioPanel.add(radio);
    }

    Button btnOk = new Button("Save");
    btnOk.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            TransferObject to = new TransferObject();
            for (RadioButton radio : radioButtons) {
                if (radio.getValue()) {
                    Integer id = Integer.parseInt(radio.getFormValue());
                    to.put("id", id);
                    mDatabaseService.setDatastoreImplementation(to, new AbstractAsyncCallback<Void>() {
                        @Override
                        public void onSuccess(Void result) {
                            Window.alert("New Implementation saved.");
                            createView();
                        }
                    });
                    break;
                }
            }
        }
    });

    panel.add(lblHeader);
    panel.add(radioPanel);
    panel.add(btnOk);
    root.add(panel);

}

From source file:de.swm.commons.mobile.client.widgets.GenericRadioButtonGroup.java

License:Apache License

@Override
public void add(Widget w) {
    assert w instanceof RadioButton : "Can only contain RadioButton widgets in RadioButtonGroup";
    RadioButton radio = (RadioButton) w;

    if (keyValueProvider != null) {
        if (this.keyValueProvider.getValue(radio.getFormValue()) != null) {
            T enumValue = this.keyValueProvider.getValue(radio.getFormValue());
            this.keyIndexMap.put(radio.getFormValue(), lastIndex);
            this.indexKeyMap.put(lastIndex, radio.getFormValue());
            radio.setText(renderer.render(enumValue));
            myFlowPanel.add(radio);//from   w  w  w  .j av a 2  s .  c  om
            lastIndex++;
        }
    } else {
        myFlowPanel.add(radio);
    }
    if (myName != null) {
        radio.setName(myName);
    }
    radio.addValueChangeHandler(this);
}

From source file:de.swm.commons.mobile.client.widgets.GenericRadioButtonGroup.java

License:Apache License

@Override
public void setValue(T value) {
    Integer indexToSelect;/*from   w  ww  .  ja va  2s .co m*/
    if (keyValueProvider != null) {
        indexToSelect = this.keyIndexMap.get(this.keyValueProvider.getKey(value));
        if (indexToSelect == null) {
            // index not found - reset all
            indexToSelect = -1;
        } else {
            // set selected radio button
            ((RadioButton) myFlowPanel.getWidget(indexToSelect)).setValue(true);
        }
        for (int i = 0; i < myFlowPanel.getWidgetCount(); i++) {
            // reset the rest
            if (i != indexToSelect) {
                ((RadioButton) myFlowPanel.getWidget(i)).setValue(false);
            }
        }
    } else {
        // support String as Type T (shortcut)
        String stringValue = (String) value;
        for (int i = 0; i < myFlowPanel.getWidgetCount(); i++) {
            RadioButton radio = (RadioButton) myFlowPanel.getWidget(i);
            if (radio.getFormValue().equals(stringValue)) {
                radio.setValue(true);
                break;
            }
        }
    }
    this.currentValue = value;
}

From source file:org.bonitasoft.forms.client.view.widget.RadioButtonGroupWidget.java

License:Open Source License

/**
 * @return the String value of the slected radio button of the group (null if no radio button is selected)
 *//*w ww.  j ava 2s .  c  o m*/
public String getValue() {

    String value = null;

    final Iterator<Widget> iterator = groupWidgets.iterator();
    while (iterator.hasNext()) {
        final RadioButton radioButton = (RadioButton) iterator.next();
        if (radioButton.getValue()) {
            value = radioButton.getFormValue();
            break;
        }
    }

    return value;
}

From source file:org.bonitasoft.forms.client.view.widget.RadioButtonGroupWidget.java

License:Open Source License

/**
 * Set the value of the widget//from   w  w  w.j  a va 2  s  .c o m
 * 
 * @param value
 */
public void setValue(final String value, boolean fireEvents) {
    if (getValue() != null && getValue().equals(value) || value != null && value.equals(getValue())) {
        fireEvents = false;
    }
    for (final RadioButton radioButton : radioButtons) {
        if (value != null && value.equals(radioButton.getFormValue())) {
            radioButton.setValue(true);
        } else {
            radioButton.setValue(false);
        }
        if (fireEvents) {
            ValueChangeEvent.fire(radioButton, true);
        }
    }
}

From source file:org.xwiki.gwt.wysiwyg.client.plugin.image.ui.ImageConfigWizardStep.java

License:Open Source License

/**
 * @return the selected image alignment//from   w  ww  . j a  v a 2  s. co  m
 */
public ImageConfig.ImageAlignment getSelectedAlignment() {
    for (RadioButton rb : alignmentOptions) {
        if (rb.getValue()) {
            return ImageConfig.ImageAlignment.valueOf(rb.getFormValue());
        }
    }
    return null;
}

From source file:org.xwiki.gwt.wysiwyg.client.plugin.image.ui.ImageConfigWizardStep.java

License:Open Source License

/**
 * Sets the passed alignment in the image alignment radio set.
 * //from   ww w. j a va  2  s.c  om
 * @param alignment the alignment to set
 */
protected void setImageAlignment(ImageConfig.ImageAlignment alignment) {
    String alignValue = alignment != null ? alignment.toString() : "";
    for (RadioButton rb : alignmentOptions) {
        if (rb.getFormValue().equals(alignValue)) {
            rb.setValue(true);
        } else {
            rb.setValue(false);
        }
    }
}