/** * Registers the field with the form and adds the field to the form layout. * * <p> * The property id must not be already used in the form. * </p> * * <p> * This field is added to the layout using the * {@link #attachField(Object, Field)} method. * </p> * * @param propertyId * the Property id the the field. * @param field * the field which should be added to the form. */ public void addField(Object propertyId, Field<?> field) { registerField(propertyId, field); attachField(propertyId, field); markAsDirty(); }
@Override public boolean hasNext() { if (i < getComponentCount()) { return true; } return false; }
/** * Focuses the first field in the form. * * @see Component.Focusable#focus() */ @Override public void focus() { final Field<?> f = getFirstFocusableField(); if (f != null) { f.focus(); } }
/** * Sets the layout that is rendered below normal form contents. No footer is * rendered if this is set to null, . * * @param footer * the new footer layout */ public void setFooter(Layout footer) { if (getFooter() != null) { getFooter().setParent(null); } getState().footer = footer; if (footer != null) { footer.setParent(this); } }
Collection<?> propertyIds) { if (getLayout() instanceof GridLayout) { GridLayout gl = (GridLayout) getLayout(); if (gridlayoutCursorX == -1) { removeAllProperties(); markAsDirty(); return; this); if (f != null) { bindPropertyToField(id, property, f); addField(id, f);
if (getLayout() != null) { for (Object property : propertyIds) { Field<?> f = getField(property); detachField(f); if (layout instanceof CustomLayout) { ((CustomLayout) layout).addComponent(f, getLayout().setParent(null); getState().layout = layout;
if (parenOfDateField instanceof Form) { Form f = (Form) parenOfDateField; Collection<?> visibleItemProperties = f.getItemPropertyIds(); for (Object fieldId : visibleItemProperties) { Field<?> field = f.getField(fieldId); if (equals(field)) { f.markAsDirty(); formFound = true; break;
/** * Sets the Tabulator index of this Focusable component. * * @see Component.Focusable#setTabIndex(int) */ @Override public void setTabIndex(int tabIndex) { super.setTabIndex(tabIndex); for (final Object id : getItemPropertyIds()) { getField(id).setTabIndex(tabIndex); } }
/** * Adds a new property to form and create corresponding field. * * @see Item#addItemProperty(Object, Property) */ @Override public boolean addItemProperty(Object id, Property property) { // Checks inputs if (id == null || property == null) { throw new NullPointerException("Id and property must be non-null"); } // Checks that the property id is not reserved if (propertyIds.contains(id)) { return false; } propertyIds.add(id); ownProperties.put(id, property); // Gets suitable field final Field<?> field = fieldFactory.createField(this, id, this); if (field == null) { return false; } // Configures the field bindPropertyToField(id, property, field); // Register and attach the created field addField(id, field); return true; }
if (isValidationVisible()) { for (final Object id : propertyIds) { Object f = fields.get(id); if (getComponentError() == null && validationError == null && currentBufferedSourceException == null) { return null; new ErrorMessage[] { getComponentError(), validationError, AbstractErrorMessage.getErrorMessageForException( currentBufferedSourceException) });
/** * Removes the property and corresponding field from the form. * * @see Item#removeItemProperty(Object) */ @Override public boolean removeItemProperty(Object id) { ownProperties.remove(id); final Field<?> field = fields.get(id); if (field != null) { propertyIds.remove(id); fields.remove(id); detachField(field); field.removeListener(fieldValueChangeListener); return true; } return false; }
return new Form();
/** * Gets the first focusable field in form. If there are enabled, * non-read-only fields, the first one of them is returned. Otherwise, the * field for the first property (or null if none) is returned. * * @return the Field. */ private Field<?> getFirstFocusableField() { Collection<?> itemPropertyIds = getItemPropertyIds(); if (itemPropertyIds != null && !itemPropertyIds.isEmpty()) { for (Object id : itemPropertyIds) { if (id != null) { Field<?> field = getField(id); if (field.isConnectorEnabled() && !field.isReadOnly()) { return field; } } } // fallback: first field if none of the fields is enabled and // writable Object id = itemPropertyIds.iterator().next(); if (id != null) { return getField(id); } } return null; }