public class UiBinding
- Object
- UiBinding
The binding framework can implicitly bind UI elements to properties, this allow seamless model to
UI mapping. Most cases allow simple binding by just using the com.codename1.ui.Component) method to seamlessly update
a property/component based on changes.
It contains the following base concepts:
com.codename1.properties.UiBinding.ObjectConverter- a converter converts from one type to another. E.g. if we want acom.codename1.ui.TextAreato map to anIntegerproperty we’d use ancom.codename1.properties.UiBinding.IntegerConverterto indicate the desired destination value.com.codename1.properties.UiBinding.ComponentAdapter- takes twocom.codename1.properties.UiBinding.ObjectConverterto convert to/from the component and property. It provides the API for event binding and value extraction/setting on the component.com.codename1.properties.UiBinding.Binding- the commit mode.com.codename1.ui.Component)- thebindhelper methods allow us to bind a component easily without exposure to these complexities.
Nested types
class UiBinding.ObjectConverter | Object converter can convert an object from one type to another e.g. a String to an integer an array to a list model. |
class UiBinding.StringConverter | Converts the source value to a String. |
class UiBinding.IntegerConverter | Converts the source value to an Integer. |
class UiBinding.DateConverter | Converts the source value to a Date. |
class UiBinding.LongConverter | Converts the source value to a Long. |
class UiBinding.FloatConverter | Converts the source value to a Float. |
class UiBinding.DoubleConverter | Converts the source value to a Double. |
class UiBinding.BooleanConverter | Converts the source value to a Boolean. |
class UiBinding.MappingConverter | Maps values to other values for conversion in a similar way to a Map this is pretty useful for API’s like picker where we have a list of Strings and we might want a list of other objects to match every string |
class UiBinding.ComponentAdapter | Adapters can be extended to allow any component to bind to a property via a converter |
class UiBinding.TextAreaAdapter | Adapts a com.codename1.ui.TextArea (and it’s subclass com.codename1.ui.TextField to binding |
class UiBinding.TextComponentAdapter | Adapts a com.codename1.ui.TextComponent to binding |
class UiBinding.CheckBoxRadioSelectionAdapter | Adapts a com.codename1.ui.CheckBox or com.codename1.ui.RadioButton to binding |
class UiBinding.RadioListAdapter | Adapts a set of com.codename1.ui.RadioButton to a selection within a list of values |
class UiBinding.PickerAdapter | Adapts a com.codename1.ui.spinner.Picker to binding |
class UiBinding.BoundTableModel | Implements table model binding, this is implemented as a class to allow additional features such as adding/removing rows |
class UiBinding.Binding | Binding allows us to have commit/auto-commit mode. |
Constructors
public UiBinding() |
Methods
Inherited methods
Constructor details
UiBinding
public UiBinding()Method details
unbind
public static void unbind(PropertyBase prop)com.codename1.properties.UiBinding.Binding#disconnect() on all bindings…Parameters
propPropertyBase- the property
unbind
public static void unbind(PropertyBusinessObject po)Parameters
poPropertyBusinessObject- the business object
isAutoCommit
public boolean isAutoCommit()#setAutoCommit(boolean)Returns
setAutoCommit
public void setAutoCommit(boolean b)com.codename1.properties.UiBinding.CommitMode#commit()
should be invoked explicitlyParameters
bboolean- true to enable auto commit mode
bind
public UiBinding.Binding bind(PropertyBusinessObject obj, Container cnt)Parameters
objPropertyBusinessObject- the business object with the properties to bind
cntContainer- a container that will be recursed for binding
Returns
bindGroup
public UiBinding.Binding bindGroup(PropertyBase prop, Object[] values, Component... cmps)Parameters
propPropertyBase- the property
valuesObject[]- the values that can be used
cmpsComponent...- the components
Returns
bind
public UiBinding.Binding bind(PropertyBase prop, Component cmp)Parameters
propPropertyBase- the property
cmpComponent- the component
Returns
bind
public UiBinding.Binding bind(PropertyBase prop, Component cmp, UiBinding.ComponentAdapter adapt)Parameters
propPropertyBase- the property
cmpComponent- the component
adaptUiBinding.ComponentAdapter- an implementation of
com.codename1.properties.UiBinding.ComponentAdapterthat allows us to define the way the component maps to/from the property
Returns
createTableModel
public UiBinding.BoundTableModel createTableModel(List<? extends PropertyBusinessObject> objects, PropertyBusinessObject prototype)Parameters
objectsList<? extends PropertyBusinessObject>- list of business objects
prototypePropertyBusinessObject- the type by which we determine the structure of the table
Returns
Table classcreateTableModel
public UiBinding.BoundTableModel createTableModel(CollectionProperty<? extends PropertyBusinessObject, ? extends Object> objects, PropertyBusinessObject prototype)Parameters
objectsCollectionProperty<? extends PropertyBusinessObject, ? extends Object>- list of business objects
prototypePropertyBusinessObject- the type by which we determine the structure of the table
Returns
Table classbindString
public void bindString(Property<String, ? extends Object> prop, TextArea ta)Parameters
propProperty<String, ? extends Object>- the property value
taTextArea- the text area
bindInteger
public void bindInteger(Property<Integer, ? extends Object> prop, TextArea ta)Parameters
propProperty<Integer, ? extends Object>- the property value
taTextArea- the text area