Hi…Vaadins,
I think it’s really need to worry while working with
Radio Buttons
in the
Vaadin Form
. I am trying to achieve Radio Buttons (with caption “Hide” and "Visible) in the Form. UI is OK. Radio Buttons are looking really very charming. But the problem is
No any button is Preselected
. How one could see the item selected by default.
Form has two
editboxes
also. And working fine. The only issue is with Radio Buttons
And the most weird thing is "
optionGroup.isSelected
" is returning
“true”
. I have made all the possible effort from my side. I wasted 2 days on it with no luck till now. really frustrated…!!
Any help is appreciated…
Thanks in advance…
Warm regards.!!
Here is the code -
public class ItemUpdate extends Window implements Button.ClickListener,FormFieldFactory
{
/**
*
*/
private static final long serialVersionUID = 1L;
private final Item item;
private Form editorForm;
private Button saveButton;
private Button cancelButton;
ItemContainer imc=new ItemContainer();
public ItemUpdate(Item item)
{
this.item=item;
editorForm=new Form();
editorForm.setFormFieldFactory(this);
editorForm.setItemDataSource(item,Arrays.asList("itemQuantity","timeToShip","visibilityStatus"));
editorForm.setWriteThrough(true);
editorForm.setImmediate(true);
saveButton = new Button("Save", this);
cancelButton = new Button("Cancel", this);
editorForm.getFooter().addComponent(saveButton);
editorForm.getFooter().addComponent(cancelButton);
getContent().setSizeUndefined();
addComponent(editorForm);
setCaption("Update Item");
center();
}
@Override
public Field createField(Item item, Object propertyId, Component uiContext) {
if("visibilityStatus".equals(propertyId))
{
// final List<String> options = Arrays.asList(new String[] { "Hide", "Visible"});
// OptionGroup optionGroup=new OptionGroup(" ", options);
OptionGroup optionGroup=new OptionGroup("VisibilityStatus");
optionGroup.addItem("Hide");
optionGroup.addItem("Visible");
optionGroup.select("Hide");
optionGroup.setImmediate(true);
return optionGroup;
}
Field field = DefaultFieldFactory.get().createField(item, propertyId,uiContext);
return field;
}
}