|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The abstraction around a list of values used by the List
component. Data sources that need to be
displayed with a list component need to implement this
interface. The ListModel
provides a read-only view of
the underlying data. The items in the list model can be accessed by
calling next()
repeatedly and accessing the item with calls
to getKey()
and getElement()
. Initially, the list
model is positioned before the first element and calls to
getKey()
and getElement()
should produce a runtime
exception until next()
is called for the first time.
A ListModel
is usually generated for each request that
a list component serves. The List
component will use its
ListModelBuilder
to generate a new ListModel
whenever it serves a request.
The items a list model iterates over are identified by two separate
objects: a key that has to be a unique string representation of the
actual list item, and an element, which represents the item itself and
is passed directly to the ListCellRenderer
. For example, a list model
that represents a list of objects that are stored in the database, the key
will usually be a suitable representation of the primary key of the object in
the database, while the element can be as simple as a string with the "pretty
name" of the object. While the element is usually only passed to a
ListCellRenderer
, the key will often be communicated to other
components that need to know which item in the list is currently selected and
can be retrieved with a call to List.getSelectedKey(com.arsdigita.bebop.PageState)
. It
is therefore important that all the components that need to work with the key
generated by a list model agree on how it represents the underlying
(database) object.
Warning: The signature of getKey
will be
changed to Obejct getKey()
after ACS 4.6
List
,
ListCellRenderer
Field Summary | |
static String |
versionId
|
Method Summary | |
Object |
getElement()
Get the element for the current list item. |
String |
getKey()
Get the key that uniquely identifies the current list item. |
boolean |
next()
Move to the next list item. |
Field Detail |
public static final String versionId
Method Detail |
public boolean next()
false
. The item's key and element can be
accessed with calls to getKey()
and getElement()
. Initially, the list model is positioned before
the first item, so that next()
has to be called once
before it is possible to access the item.
true
if the model is positioned on a valid item
after the call returns.public Object getElement()
ListModel
and should be documented
there.
This method can only be called successfully if the previous cal to
next()
returned true
.
next()
public String getKey()
This method can only be called successfully if the previous cal to
next()
returned true
.
next()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |