/** * Binds the provided component to the specified property of the model instance * associated with this {@link DataBinder}. If the provided component already * participates in another binding managed by this {@link DataBinder}, a * {@link ComponentAlreadyBoundException} will be thrown. * * @param component * The UI component the model instance should be bound to, must not be * null. * @param property * The name of the model property that should be used for the * binding, following Java bean conventions. Chained (nested) * properties are supported and must be dot (.) delimited (e.g. * customer.address.street). Must not be null. * @return the same {@link DataBinder} instance to support call chaining. * @throws NonExistingPropertyException * If the {@code model} does not have a property with the given * name. * @throws InvalidPropertyExpressionException * If the provided property chain expression is invalid. * @throws ComponentAlreadyBoundException * If the provided {@code component} is already bound to a property of * the model. */ public DataBinder<T> bind(final Object component, final String property) { return bind(component, property, null); }
/** * Binds the provided component to the specified property of the model instance * associated with this {@link DataBinder}. If the provided component already * participates in another binding managed by this {@link DataBinder}, a * {@link ComponentAlreadyBoundException} will be thrown. * * @param component * The UI component the model instance should be bound to, must not be * null. * @param property * The name of the model property that should be used for the * binding, following Java bean conventions. Chained (nested) * properties are supported and must be dot (.) delimited (e.g. * customer.address.street). Must not be null. * @return the same {@link DataBinder} instance to support call chaining. * @throws NonExistingPropertyException * If the {@code model} does not have a property with the given * name. * @throws InvalidPropertyExpressionException * If the provided property chain expression is invalid. * @throws ComponentAlreadyBoundException * If the provided {@code component} is already bound to a property of * the model. */ public DataBinder<T> bind(final Object component, final String property) { return bind(component, property, null); }
/** * Binds the provided component to the specified property of the model instance * associated with this {@link DataBinder}. If the provided component already * participates in another binding managed by this {@link DataBinder}, a * {@link ComponentAlreadyBoundException} will be thrown. * * @param component * The UI component the model instance should be bound to, must not be * null. * @param property * The name of the model property that should be used for the * binding, following Java bean conventions. Chained (nested) * properties are supported and must be dot (.) delimited (e.g. * customer.address.street). Must not be null. * @return the same {@link DataBinder} instance to support call chaining. * @throws NonExistingPropertyException * If the {@code model} does not have a property with the given * name. * @throws InvalidPropertyExpressionException * If the provided property chain expression is invalid. * @throws ComponentAlreadyBoundException * If the provided {@code component} is already bound to a property of * the model. */ public DataBinder<T> bind(final Object component, final String property) { return bind(component, property, null); }
bind(component, property, converter, StateSync.FROM_MODEL); return this;
bind(component, property, converter, StateSync.FROM_MODEL); return this;
bind(component, property, converter, StateSync.FROM_MODEL); return this;
@SuppressWarnings("rawtypes") final Converter converter, final StateSync initialState) { return bind(component, property, converter, initialState, false);
@SuppressWarnings("rawtypes") final Converter converter, final StateSync initialState) { return bind(component, property, converter, initialState, false);
@SuppressWarnings("rawtypes") final Converter converter, final StateSync initialState) { return bind(component, property, converter, initialState, false);
public T bind(T target, Map<String, String> newValues) { DataBinder binder = new DataBinder(target); binder.setAllowedFields(getAllowedFields()); binder.bind(new MutablePropertyValues(newValues)); return target; }
private void bindJSONToObject(Object obj, String json) throws IOException, JsonProcessingException { MutablePropertyValues mpv = new MutablePropertyValues(); JsonNode rootNode = new ObjectMapper().readTree(json); for (Iterator<Entry<String, JsonNode>> iter = rootNode.getFields(); iter.hasNext(); ) { Entry<String, JsonNode> entry = iter.next(); String name = entry.getKey(); JsonNode node = entry.getValue(); if (node.isArray()) { List<String> values = new ArrayList<String>(); for (JsonNode elem : node) { values.add(elem.getTextValue()); } mpv.addPropertyValue(name, values); if (logger.isDebugEnabled()) { logger.debug(name + "=" + ArrayUtils.toString(values)); } } else { mpv.addPropertyValue(name, node.getTextValue()); if (logger.isDebugEnabled()) { logger.debug(name + "=" + node.getTextValue()); } } } DataBinder dataBinder = new DataBinder(obj); dataBinder.bind(mpv); }
Person person = new Person(); DataBinder dataBinder = new DataBinder(person); MutablePropertyValues mpv = new MutablePropertyValues(); mpv.add("name", "John Doe"); mpv.add("age", 25); mpv.add("contact.street", "1st Street"); mpv.add("contact.number", 12345); dataBinder.bind(mpv);
binder.bind(widget, formField.getFieldBinding(), valueConverter,