Objects.requireNonNull(binding, "null is not a valid editor field"); if (!(binding.getField() instanceof Component)) { throw new IllegalArgumentException( "Binding target must be a component.");
/** * Notifies validation status handlers for bindings that pass given filter. * The filter should return {@code true} for each * {@link BindingValidationStatus} that should be delegated to the status * handler in the binding. * * @see #notifyBindingValidationStatusHandlers() * * @param filter * the filter to select bindings to run status handling for * * @since 8.2 */ public void notifyBindingValidationStatusHandlers( SerializablePredicate<BindingValidationStatus<?>> filter) { bindingStatuses.stream().filter(filter).forEach(s -> s.getBinding() .getValidationStatusHandler().statusChange(s)); } }
/** * Removes the given Binding from this Binder. * * @see Binder#removeBinding(HasValue) * @see com.vaadin.ui.AbstractComponent#setComponentError * @see com.vaadin.ui.AbstractComponent#setRequiredIndicatorVisible * * @param binding * the binding to remove * * @since 8.2 * * @throws IllegalArgumentException * if the given Binding is not in this Binder */ public void removeBinding(Binding<BEAN, ?> binding) throws IllegalArgumentException { Objects.requireNonNull(binding, "Binding can not be null"); if (!bindings.contains(binding)) { throw new IllegalArgumentException( "Provided Binding is not in this Binder"); } binding.unbind(); }
} else { c = (Component) binding.get().getField();
protected Component getComponentFor(ET pojo, String property) { EditorStuff editorsstuff = provideEditorStuff(pojo); Component c = null; Optional<Binder.Binding<ET, ?>> binding = editorsstuff.bfg.getBinding(property); if (binding.isPresent()) { c = (Component) binding.get().getField(); } else { try { // property that is not a property editor field but custom UI "column" java.lang.reflect.Field f = editorType.getDeclaredField(property); f.setAccessible(true); c = (Component) f.get(editorsstuff.editor); } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) { Logger.getLogger(AbstractElementCollection.class.getName()). log(Level.SEVERE, null, ex); } if (c == null) { c = new Label(""); } } return c; }
.map(b -> b.validate(false)).collect(Collectors.toList());
/** * Informs the Binder that a value in Binding was changed. This method will * trigger validating and writing of the whole bean if using * {@link #setBean(Object)}. If using {@link #readBean(Object)} only the * field validation is run. * * @param binding * the binding whose value has been changed * @param event * the value change event * @since 8.2 */ protected void handleFieldValueChange(Binding<BEAN, ?> binding, ValueChangeEvent<?> event) { changedBindings.add(binding); if (getBean() != null) { doWriteIfValid(getBean(), changedBindings); } else { binding.validate(); } }
/** * Validates the field value and returns a {@code ValidationStatus} * instance representing the outcome of the validation. This method is a * short-hand for calling {@link #validate(boolean)} with * {@code fireEvent} {@code true}. * * @see #validate(boolean) * @see Binder#validate() * @see Validator#apply(Object, ValueContext) * * @return the validation result. */ public default BindingValidationStatus<TARGET> validate() { return validate(true); }
/** * Gets the bound field for this status. * * @return the field */ public HasValue<?> getField() { return getBinding().getField(); } }
private boolean isFieldBound(Field memberField, Object objectWithMemberFields) { try { HasValue field = (HasValue) getMemberFieldValue(memberField, objectWithMemberFields); return bindings.stream() .anyMatch(binding -> binding.getField() == field); } catch (Exception e) { return false; } }