Class BindingInfo

All Implemented Interfaces:
Serializable, Cloneable, Copyable, DictionaryBean, UifDictionaryBean

public class BindingInfo extends UifDictionaryBeanBase implements Serializable
Provides binding configuration for an DataBinding component (attribute or collection)

From the binding configuration the binding path is determined (if not manually set) and used to set the path in the UI or to get the value from the model

Author:
Kuali Rice Team (rice.collab@kuali.org)
See Also:
  • Constructor Details

    • BindingInfo

      public BindingInfo()
  • Method Details

    • setDefaults

      public void setDefaults(View view, String propertyName)
      Sets up some default binding properties based on the view configuration and the component's property name

      Sets the bindingName (if not set) to the given property name, and if the binding object path has not been set uses the default binding object path setup for the view

      Parameters:
      view - the view instance the component belongs to
      propertyName - name of the property (relative to the parent object) the component binds to
    • getBindingPath

      public String getBindingPath()
      Path to the property on the model the component binds to. Uses standard dot notation for nested properties. If the binding path was manually set it will be returned as it is, otherwise the path will be formed by using the binding object path and the bind prefix

      e.g. Property name 'foo' on a model would have binding path "foo", while property name 'name' of the nested model property 'account' would have binding path "account.name"

      Returns:
      binding path
    • getBindingPrefixForNested

      public String getBindingPrefixForNested()
      Returns the binding prefix string that can be used to setup the binding on DataBinding components that are children of the component that contains the BindingInfo. The binding prefix is formed like the binding path but without including the object path
      Returns:
      binding prefix for nested components
    • getPropertyAdjustedBindingPath

      public String getPropertyAdjustedBindingPath(String propertyPath)
      Returns the binding path that is formed by taking the binding configuration of this BindingInfo instance with the given property path as the binding name. This can be used to get the binding path when just a property name is given that is assumed to be on the same parent object of the field with the configured binding info

      Special check is done for org.kuali.rice.krad.uif.UifConstants#NO_BIND_ADJUST_PREFIX prefix on the property name which indicates the property path is the full path and should not be adjusted. Also, if the property is prefixed with org.kuali.rice.krad.uif.UifConstants#FIELD_PATH_BIND_ADJUST_PREFIX, this indicates we should only append the binding object path

      Parameters:
      propertyPath - path for property to return full binding path for
      Returns:
      full binding path
    • getBindingPathPrefix

      public String getBindingPathPrefix()
      Returns the binding path prefix to affix before the binding path or property adjusted binding path.
      Returns:
      the binding path prefix to affix before a binding path.
    • addToBindByNamePrefix

      public void addToBindByNamePrefix(String bindPrefix)
      Helper method for adding a path to the binding prefix
      Parameters:
      bindPrefix - path to add
    • setBindingPath

      public void setBindingPath(String bindingPath)
      Setter for the binding path. Can be left blank in which the path will be determined from the binding configuration
      Parameters:
      bindingPath -
    • isBindToForm

      public boolean isBindToForm()
      Indicates whether the component binds directly to the form (that is its bindingName gives a property available through the form), or whether is binds through a nested form object. If bindToForm is false, it is assumed the component binds to the object given by the form property whose path is configured by bindingObjectPath.
      Returns:
      true if component binds directly to form, false if it binds to a nested object
    • setBindToForm

      public void setBindToForm(boolean bindToForm)
      Setter for the bind to form indicator
      Parameters:
      bindToForm -
    • getBindingName

      public String getBindingName()
      Gives the name of the property that the component binds to. The name can be nested but not the full path, just from the parent object or in the case of binding directly to the form from the form object

      If blank this will be set from the name field of the component

      Returns:
      name of the bind property
    • setBindingName

      public void setBindingName(String bindingName)
      Setter for the bind property name
      Parameters:
      bindingName -
    • getBindByNamePrefix

      public String getBindByNamePrefix()
      Prefix that will be used to form the binding path from the component name. Typically used for nested collection properties
      Returns:
      binding prefix
    • setBindByNamePrefix

      public void setBindByNamePrefix(String bindByNamePrefix)
      Setter for the prefix to use for forming the binding path by name
      Parameters:
      bindByNamePrefix -
    • getCollectionPath

      public String getCollectionPath()
      If field is part of a collection field, gives path to collection

      This is used for metadata purposes when getting finding the attribute definition from the dictionary and is not used in building the final binding path

      Returns:
      path to collection
    • setCollectionPath

      public void setCollectionPath(String collectionPath)
      Setter for the field's collection path (if part of a collection)
      Parameters:
      collectionPath -
    • getBindingObjectPath

      public String getBindingObjectPath()
      For attribute fields that do not belong to the default form object (given by the view), this field specifies the path to the object (on the form) the attribute does belong to.

      e.g. Say we have an attribute field with property name 'number', that belongs to the object given by the 'account' property on the form. The form object path would therefore be set to 'account'. If the property belonged to the object given by the 'document.header' property of the form, the binding object path would be set to 'document.header'. Note if the binding object path is not set for an attribute field (or any DataBinding component), the binding object path configured on the View will be used (unless bindToForm is set to true, where is assumed the property is directly available from the form).

      Returns:
      path to object from form
    • setBindingObjectPath

      public void setBindingObjectPath(String bindingObjectPath)
      Setter for the object path on the form
      Parameters:
      bindingObjectPath -
    • isBindToMap

      public boolean isBindToMap()
      Indicates whether the parent object for the property that we are binding to is a Map. If true the binding path will be adjusted to use the map key syntax
      Returns:
      true if the property binds to a map, false if it does not
    • setBindToMap

      public void setBindToMap(boolean bindToMap)
      Setter for the bind to map indicator
      Parameters:
      bindToMap -
    • isIgnoreDefaultBindingObjectPath

      public boolean isIgnoreDefaultBindingObjectPath()
      Indicates whether we should ignore the defaultBindingObjectPath set for this view (true) or not (false). This is mainly so that some sections of a view can be bound to the default path while others are not.
      Returns:
      true if this component should ignore the default binding path of its containing view, false if it should behave normally
    • setIgnoreDefaultBindingObjectPath

      public void setIgnoreDefaultBindingObjectPath(boolean ignoreDefaultBindingObjectPath)