public interface ListModel
Definition of an interface that is used to obtain the content of a list box or combo box component.
When lists or combo boxes or similar components are to be displayed their content must be specified. This can be a list of static texts in the most simple cases, but also the results of a data base query. To support all of these possibilities the form builder library introduces this interface which serves as an abstraction of a real data source.
This interface defines methods for obtaining the data to be displayed. The
displayed data need not be the same that will be stored in the form bean for
this element, so it is also possible to define a specific value for each
element to be displayed. The getType()
method will determine
the data type of the corresponding property in the form bean.
Modifier and Type | Method and Description |
---|---|
Object |
getDisplayObject(int index)
Returns the display object with the given index.
|
Class<?> |
getType()
Returns the data object of this list model.
|
Object |
getValueObject(int index)
Returns the value object with the given index.
|
int |
size()
Returns the number of entries in this model.
|
int size()
Object getDisplayObject(int index)
index
- the index (0 based)Object getValueObject(int index)
Returns the value object with the given index.
This method makes sense when the display objects are different from the
values that should be stored when corresponding display objects are
selected. E.g. the display objects might be simple strings that represent
complex data objects. When a string is selected the component's data
really is the data object behind this string. In this case the
getValueObject()
method would return the complex data
objects, while getDisplayObject()
would return
corresponding string representations.
When working with a fix set of options from which the user can select one
or some, it is often useful to store the indices of the selected display
objects. Imagine a combo box that offer the choices "yes",
"no", and "maybe". In the bean of the form that
contains this combo box it makes sense to store the values 0, 1, or 2
depending on the user's selection rather than the (language dependend)
string values. To achieve this, the getValueObject()
method can always return null . Then as values always the
corresponding indices will be used as values. Note: an implementation
must not mix these variants; either it must return null for all
of its values or none.
index
- the index (0 based)Class<?> getType()
Copyright © 2016 The JGUIraffe Team. All rights reserved.