Base data model for breadCrumb, dropdownListBox and listBox.
Method |
Description |
Argument |
Return value |
addItem |
Add item (entry) to the list |
(java.lang.String key, |
void |
addSelection |
Selects an item with the given key. Clicking on an selected item does NOT fire an event. |
(java.lang.String sel) |
void |
getKeyByIndex |
Returns the key of an item with specified index. |
(int index) |
java.lang.String |
getKeys |
Returns an iterator for all keys in the list. |
() |
java.util.Iterator |
getMultiSelection |
Returns the keys of the currently selected items. The model must be a multi selection model. |
() |
lang.String[] |
getNameofKeyColumn |
Returns the name of the column containing the key values if the list model is associated with a table (for example, JCOListModel). |
() |
java.lang.String |
getNameofTextColumn |
Gets the name of the column containing the visible texts if the list model is associated with a table (for example, JCOListModel). |
() |
java.lang.String |
getSingleSelection |
Gets the key of the currently selected item if the model is a single selection model. |
() |
java.lang.String |
getTextByIndex |
Returns the visible text of an item with the specified index. |
(int index) |
java.lang.String |
getTextForKey |
Returns the text associated with the key. |
(java.lang.String key) |
java.lang.String |
isSelected |
Returns the status (selected or not selected) for an item with the specified index. |
(int index) |
boolean |
isSelected |
Returns the status (selected or not selected) for an item with the specified index. |
(java.lang.String key) |
boolean |
isSingleSelection |
Returns the status of the model (Singleselect or Multiselect). |
() |
boolean |
removeSelection |
Deselects an item with the given key. |
(java.lang.String sel) |
void |
setNameOfKeyColumn |
Sets the name of the column containing the key values if the list model is associated with a table (for example, JCOListModel). This method has now visible effect. |
(java.lang.String n) |
void |
setNameOfTextColumn |
Sets the name of the column containing the visible texts if the list model is associated with a table (for example, JCOListModel). This method has now visible effect. |
(java.lang.String n) |
void |
setSelection |
Selects an item with the given key. The selection from previous selected items is removed. Clicking on an selected item does NOT fire an event. |
(java.lang.String key) |
void |
setSingleSelection |
Defines the selection mode for the model. Set to true one item can be selected at one time, set to false multiple entries can be selected. If the model is set to multiple select mode, no event for the control must be defined to avoid events when multiple selects are made. Multiple selects can be made by holding the <Shift> or <Strg>/<Ctrl> key down and click on the entries. |
(boolean selection) |
void |
size |
Returns the number of items/entries in the list. |
() |
int |
Setting the model
import com.sap.htmlb.BreadCrumb; |
Getting selected items
The example assumes that a listBox in a JSP has the attribute 'onSelect' set, so that an event is fired when the user clicks in the list. We define a method 'onSelect' in the DynPage to handle the event. The method grabs the listBox id, retrieves the selected items and put the string of the selected items in a StringBuffer.
public void onSelect(Event event) throws PageException { |