Interface Binding

All Known Subinterfaces:
NotifiableBinding

public interface Binding
Handle returned by Binders.bind. Lets the caller refresh the components from the model (e.g. after the model was mutated outside the form), re-read the model from the components (e.g. before a save), tear down the listeners installed for two-way bindings, or reach into the Validator the binder configured from the model's @Required / @Length / @Regex / @Email / @Url / @Numeric / @ExistIn / @Validate annotations.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Pulls current component values back into the model.
    void
    Removes every listener the binder added so the form can be garbage- collected without keeping the model alive.
    The Validator populated from the model's validation annotations.
    void
    Pushes the current model values into every bound component.
  • Method Details

    • refresh

      void refresh()
      Pushes the current model values into every bound component.
    • commit

      void commit()
      Pulls current component values back into the model. Useful before validating / submitting a form when none of the bindings is two-way.
    • disconnect

      void disconnect()
      Removes every listener the binder added so the form can be garbage- collected without keeping the model alive.
    • getValidator

      Validator getValidator()

      The Validator populated from the model's validation annotations.

      Each @Bind field that carries one or more of @Required, @Length, @Regex, @Email, @Url, @Numeric, @ExistIn, @Validate contributes a com.codename1.ui.validation.Constraint against the matching component. Multiple annotations on the same field are combined under a GroupConstraint (first failure wins), matching the behaviour of Validator.addConstraint(Component, Constraint...).

      The returned validator is never null -- call addSubmitButtons to gate a submit Button until every constraint passes, set setValidateOnEveryKey for live feedback, or call isValid() to gate an action programmatically. When the model has no validation annotations the validator is empty and isValid() returns true.