Last active
August 29, 2015 14:19
-
-
Save KrishnaKotari/1306fbf5ef9316c2bc5a to your computer and use it in GitHub Desktop.
All code related to Part 4 of my series on Vaadin Grid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Sets the grid editor to be enabled | |
grid.setEditorEnabled(true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Setting the field group | |
grid.setEditorFieldGroup(getFieldGroup()); | |
/** | |
* @return | |
*/ | |
private FieldGroup getFieldGroup() { | |
BeanFieldGroup<VehicleInfo> beanFieldGroup = new BeanFieldGroup<VehicleInfo>( | |
VehicleInfo.class); | |
beanFieldGroup.addCommitHandler(new CommitHandler() { | |
/** | |
* | |
*/ | |
private static final long serialVersionUID = 6062316515368687380L; | |
@Override | |
public void preCommit(CommitEvent commitEvent) | |
throws CommitException { | |
} | |
@Override | |
public void postCommit(CommitEvent commitEvent) | |
throws CommitException { | |
Notification.show("Saved Successfully!!", | |
Type.TRAY_NOTIFICATION); | |
} | |
}); | |
return beanFieldGroup; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Customizing the editor fields | |
grid.getColumn("manufacturer").setEditorField( | |
getComboBox("Manufacturer is required!", | |
Arrays.asList(Manufacturer.values()))); | |
/** | |
* @return | |
*/ | |
private Field<?> getComboBox(String requiredErrorMsg, Collection<?> items) { | |
ComboBox comboBox = new ComboBox(); | |
comboBox.setNullSelectionAllowed(true); | |
IndexedContainer container = new IndexedContainer(items); | |
comboBox.setContainerDataSource(container); | |
comboBox.setRequired(true); | |
comboBox.setRequiredError(requiredErrorMsg); | |
return comboBox; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment