|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.bebop.Completable
com.arsdigita.bebop.SimpleComponent
com.arsdigita.bebop.List
A List
, similar to a javax.swing.JList
, that
keeps track of a sequence of items and selections of one or more of
these items. A separate model, ListModel
, is used to represent
the items in the list.
ListModel
,
ListModelBuilder
,
ListCellRenderer
Field Summary | |
static ListModel |
EMPTY_MODEL
A ListModel that has no rows. |
static int |
HORIZONTAL
Horizontal List layout. |
static String |
SELECT_EVENT
The name of the event the list sets when producing links that change which item is selected. |
static String |
SELECTED
The name of the StringParameter that the list uses to keep track of which item is selected. |
static String |
versionId
|
static int |
VERTICAL
Vertical List layout. |
Fields inherited from class com.arsdigita.bebop.SimpleComponent |
m_attr |
Fields inherited from interface com.arsdigita.bebop.util.BebopConstants |
BEBOP_BORDER, BEBOP_BOXPANEL, BEBOP_CELL, BEBOP_CHECKBOX, BEBOP_CHECKBOXGROUP, BEBOP_COLUMNPANEL, BEBOP_DATE, BEBOP_DATETIME, BEBOP_DHTMLEDITOR, BEBOP_FORMERRORS, BEBOP_FORMWIDGET, BEBOP_GRIDPANEL, BEBOP_LIST, BEBOP_MULTISELECT, BEBOP_OPTION, BEBOP_PAD, BEBOP_PADFRAME, BEBOP_PANELROW, BEBOP_PORTAL, BEBOP_PORTLET, BEBOP_RADIO, BEBOP_RADIOGROUP, BEBOP_SEG_BODY, BEBOP_SEG_HEADER, BEBOP_SEG_PANEL, BEBOP_SEGMENT, BEBOP_SELECT, BEBOP_TABLE, BEBOP_TABLEBODY, BEBOP_TABLEROW, BEBOP_TEXTAREA |
Fields inherited from interface com.arsdigita.bebop.Component |
BEBOP_XML_NS, CLASS, ID, ON_CLICK, STYLE |
Constructor Summary | |
List()
Creates an empty List . |
|
List(ListModelBuilder b)
Creates a new List that uses the specified
list model builder to generate
per-request ListModels . |
|
List(Map map)
Creates a new List from a map. |
|
List(Object[] values)
Creates a new List from an array of objects. |
|
List(SingleSelectionModel selection)
Create an empty List . |
Method Summary | |
void |
addActionListener(ActionListener l)
Adds an action listener. |
void |
addChangeListener(ChangeListener l)
Adds a change listener. |
void |
clearSelection(PageState state)
Clears the selection in the request represented by state . |
protected ChangeListener |
createChangeListener()
Creates the change listener that is used for forwarding change events fired by the selection model to change listeners registered with the list. |
protected void |
fireActionEvent(PageState state)
Fires an action event signalling that the list received the request submission. |
protected void |
fireStateChanged(PageState state)
Fires a change event to signal that the selected list item has changed in the request represented by state . |
void |
generateXML(PageState state,
Element parent)
Generates XML representing the items in the list. |
ListCellRenderer |
getCellRenderer()
Returns the renderer currently used for rendering list items. |
Component |
getEmptyView()
Gets the empty view component. |
int |
getLayout()
Retrieve the current List layout. |
ListModel |
getModel(PageState state)
Gets the list model used in processing the request represented by state . |
ListModelBuilder |
getModelBuilder()
Returns the model builder currently used to build each request-specific ListModel . |
Object |
getSelectedKey(PageState state)
Gets the key for the selected list item. |
SingleSelectionModel |
getSelectionModel()
Gets the selection model. |
boolean |
getStateParamsAreRegistered()
|
boolean |
isSelected(PageState state)
Returns true if one of the list items is currently selected. |
void |
register(Page p)
Registers this List and its state parameter(s) with the
specified page. |
void |
removeActionListener(ActionListener l)
Removes a previously added action listener. |
void |
removeChangeListener(ChangeListener l)
Removes a change listener. |
void |
respond(PageState state)
Responds to a request in which this List was the targetted
component. |
void |
setCellRenderer(ListCellRenderer r)
Sets the cell renderer to be used when generating output with or generateXML . |
void |
setEmptyView(Component c)
Sets the empty view component, which is shown if there are no items in the list. |
void |
setLayout(int layout)
Set the current List layout. |
void |
setListData(Map map)
Sets the list to use the entries in map . |
void |
setListData(Object[] values)
Sets the list to use for the values in values . |
void |
setModelBuilder(ListModelBuilder b)
Sets the model builder used to build each request-specific ListModel . |
void |
setSelectedKey(PageState state,
String key)
Sets the selection to the one with the specified key. |
void |
setSelectionModel(SingleSelectionModel m)
Sets the selection model that the list uses to keep track of the currently selected list item. |
void |
setStateParamsAreRegistered(boolean val)
This method is part of a mechanism to freakishly allow List's to be used as parent classes for components that do not have their state params registered with the page. |
Methods inherited from class com.arsdigita.bebop.SimpleComponent |
children, clone, exportAttributes, getAttribute, getClassAttr, getIdAttr, getKey, getMetaDataAttribute, getStyleAttr, hasAttributes, isLocked, isVisible, lock, register, setAttribute, setClassAttr, setIdAttr, setKey, setMetaDataAttribute, setStyleAttr, setVisible |
Methods inherited from class com.arsdigita.bebop.Completable |
addCompletionListener, fireCompletionEvent |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String versionId
public static final String SELECTED
public static final String SELECT_EVENT
public static final int VERTICAL
Vertical List layout.
public static final int HORIZONTAL
Horizontal List layout.
public static final ListModel EMPTY_MODEL
ListModel
that has no rows.
Constructor Detail |
public List(ListModelBuilder b)
List
that uses the specified
list model builder to generate
per-request ListModels
.
b
- the model builder used for this listpublic List()
List
.
public List(SingleSelectionModel selection)
List
.
public List(Object[] values)
List
from an array of objects. Uses an
internal ListModelBuilder
. Each ListModel
that is
built will
iterate through the entries of the object, returning the objects from
calls to ListModel.getElement()
and the corresponding index,
which is converted to a String
from calls to ListModel.getKey()
.
values
- an array of itemssetListData(Object[] v)
public List(Map map)
List
from a map. Uses an internal ListModelBuilder
. Each ListModel
that is built will iterate
through the entries in map
in the order in which they are
returned by map.entrySet().iterator()
. Calls to ListModel.getElement()
return one value in map
. Calls to
ListModel.getElement()
return the corresponding key, which is
converted
to a String
by calling toString()
on the key.
map
- a key-value mapping for the list itemsMethod Detail |
public void register(Page p)
List
and its state parameter(s) with the
specified page.
register
in interface Component
register
in class SimpleComponent
p
- the page this list is contained inpublic void respond(PageState state) throws javax.servlet.ServletException
List
was the targetted
component. Calls to this method should only be made through links
generated by this list.
Determines the new selected element and fires a ChangeEvent
if it has changed. After that, fires an ActionEvent
.
respond
in interface Component
respond
in class SimpleComponent
state
- the state of the current request
javax.servlet.ServletException
- if the control event is unknown.fireStateChanged
,
fireActionEvent
public void generateXML(PageState state, Element parent)
ListCellRenderer
. generateXML
is called on each component returned by the renderer.
The XML that is generated has the following form:
<bebop:list mode="single" %bebopAttr;> <bebop:cell [selected="selected"] key="itemKey"> ... XML generated for component returned by renderer ... </bebop:cell> ... more <bebop:cell> elements, one for each list item ... </bebop:list>
generateXML
in interface Component
generateXML
in class SimpleComponent
state
- the state of the current requestparent
- the element into which XML is generatedListCellRenderer
public int getLayout()
Retrieve the current List layout.
public void setLayout(int layout)
Set the current List layout.
layout
- New layout value, must be List.VERTICAL or List.HORIZONTALpublic void setStateParamsAreRegistered(boolean val)
public boolean getStateParamsAreRegistered()
public final ListCellRenderer getCellRenderer()
setCellRenderer
,
ListCellRenderer
public final void setCellRenderer(ListCellRenderer r)
generateXML
.
r
- a ListCellRenderer
valueListCellRenderer
public final ListModelBuilder getModelBuilder()
ListModel
.
ListModelBuilder
value.setModelBuilder
,
ListModelBuilder
public final void setModelBuilder(ListModelBuilder b)
ListModel
.
b
- a ListModelBuilder
valueListModelBuilder
public final void setEmptyView(Component c)
c
- the new empty view componentpublic final Component getEmptyView()
public ListModel getModel(PageState state)
state
.
state
- the state of the current request
state
.public void setListData(Object[] values)
values
. Each ListModel
that is built will iterate through the entries of the object,
returning the objects from calls to ListModel.getElement()
and
the corresponding index, which is converted to a String
from calls to ListModel.getKey()
.
values
- an array of itemspublic void setListData(Map map)
map
. Each ListModel
that is built will iterate through the entries in
map
in the order in which they are returned by
map.entrySet().iterator()
. Calls to ListModel.getElement()
return one value in map
. Calls to
ListModel.getElement()
return the corresponding key, which is
converted to a String
by calling toString()
on the key.
map
- a key-value mapping for the list itemspublic final SingleSelectionModel getSelectionModel()
public final void setSelectionModel(SingleSelectionModel m)
m
- the new selection modelpublic Object getSelectedKey(PageState state)
isSelected
is true
.
state
- the state of the current request
public void setSelectedKey(PageState state, String key)
key
was not already selected, fires the ChangeEvent
.
state
- the state of the current requestkey
- the key for the selected list itemfireStateChanged
public boolean isSelected(PageState state)
true
if one of the list items is currently selected.
state
- the state of the current request
true
if one of the list items is selected
false
otherwise.public void clearSelection(PageState state)
state
.
state
- the state of the current requestprotected ChangeListener createChangeListener()
public void addChangeListener(ChangeListener l)
l
- the change listener to run when the selected item changes in
a requestpublic void removeChangeListener(ChangeListener l)
addChangeListener
, although no
error is signalled if the change listener is not found among the
list's listeners.
l
- the change listener to remove from the listprotected void fireStateChanged(PageState state)
state
. The source of the
event is the list.
state
- the state of the current requestpublic void addActionListener(ActionListener l)
respond
is
called on the list. This gives clients a way to track mouse clicks
received by the list.
respond
public void removeActionListener(ActionListener l)
addActionListener
protected void fireActionEvent(PageState state)
state
- the state of the current requestrespond
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |