The XdevComboBox is a combination of an input field, a button, and a drop-down list, from which the user can select a value. The drop-down list predominantly contains the values contained in a given column in the database table.
The input field of an XdevComboBox is editable by default. The drop-down list entries are automatically re-filtered in accordance with each input. The selected entry is displayed in the XdevComboBox. The XdevComboBox is a form component and can be persisted via the XdevFieldGroup.
XdevBeanItemContainer - Standard data container. The allocation is set using the setContainerDataSource method.
// Generates a new XdevBeanItemContainer 'productList' XdevBeanItemContainer<Product> productList = new XdevBeanItemContainer<Product>(Product.class); // Sets the XdevBeanItemContainer comboBox.setContainerDataSource(productList); |
Add entries - Manually add entries to the XdevComboBox.
comboBox.addItem("Eintrag 1"); comboBox.addItem("Eintrag 2"); |
Direct allocation of multiple entries.
listSelect.addItems("Eintrag 1", "Eintrag 2", "Eintrag 3", "Eintrag 4"); |
Selected object - Returns the selected object (entity) - Example: category entity.
Category Category = comboBox.getSelectedItem(); |
or
Category Category = (Category)comboBox.getValue(); |
Remove elements - Removes all the elements from the XdevComboBox.
comboBox.removeAllItems(); |
Select element - Automatic selection of an entry - Example: first entry.
Collection<?> itemIds = comboBox.getItemIds(); comboBox.setValue(((List<Category>)itemIds).get(0)); |
Reset selection - Sets the selection to the initial state. This triggers a valueChange event.
comboBox.clear(); |
Read random value of the selected object - Example: "Category name"
String categoryName = comboBox.getSelectedItem().getBean().getCategoryname(); |
Read XdevComboBox data - Generates a new XdevBeanContainer productContainer of Product category and assigns this with the getContainerDataSource method to XdevBeanContainer of the XdevComboBox.
XdevBeanContainer<Product> productContainer = comboBox.getContainerDataSource(); |