com.sapportals.htmlb

Class ListBox

java.lang.Object
  extended bycom.sapportals.htmlb.Component
      extended bycom.sapportals.htmlb.EventValidationComponent
          extended bycom.sapportals.htmlb.ListBox
All Implemented Interfaces:
IEventValidationComponent, LabeledComponent

public class ListBox
extends EventValidationComponent
implements LabeledComponent

Title: List Box Description: This class renders a List Box.

Copyright 2004 SAP AG


Field Summary
static String UI_ID
           
 
Constructor Summary
ListBox(String name)
          Creates a ListBox
 
Method Summary
 void addItem(String key, String text)
          Inserts a new item at the end of the list.
 void addSelection(String selection)
          Add an item to the selected items list
protected  IListModel createDefaultModel()
          Internal constructor for a default ListModel.
 Iterator getKeys()
          get an Iterator for all keys contained in this DropdownListBox
 IListModel getModel()
          get the model underlying this ListBox
 String[] getMultiSelection()
          Returns a list of selected items
 String getNameOfKeyColumn()
          get the name of the column that contains the keys.
 String getNameOfValueColumn()
          get the name of the column that contains the visible texts.
 String getOnClientSelect()
          get the JavaScript fragment that is executed on the client side if the user changes the selection
 String getOnSelect()
          get the event identifier for a selection event.
 String getSingleSelection()
          Returns the selected items
 int getSize()
          Returns the size of ListBox rendered in the HTML-Tag <select size="size"
 String getTextForKey(String key)
          Returns the text of a ListBox item
 String getTooltip()
          gets the Tooltip for this ListBox.
 String getUI()
          get a identification String for the renderer that is unique across all supported components.
 String getWidth()
          Returns the width of ListBox rendered in the HTML-Tag <select ... style="width:xxx;"
protected  void initFromPageContext(IPageContext pc, String baseId)
          internal use only.
 boolean isLabeled()
          checks if a label has been assigned to this component.
 boolean isSelected(String key)
          Checks if an item is in the selected item list
 void removeSelection(String selection)
          Removes an item from the selected items list
 void setLabeled(boolean isLabeled)
          notify the component that a label has been assigned to it.
 void setModel(IListModel model)
          set the model for this ListBox
 void setNameOfKeyColumn(String nameOfKeyColumn)
          specify the name of the column that contains the keys.
 void setNameOfValueColumn(String nameOfValueColumn)
          specify the name of the column that contains the visible texts.
 void setOnClientSelect(String onClientSelect)
          specify a clientside JavaScript that should be executed if the user changes the selection
 void setOnSelect(String onSelect)
          set the event identifier for a selection event.
 void setSingleSelection(String selection)
          Returns the selected items
 void setSize(int size)
          Sets the size of ListBox rendered in the HTML-Tag <select size="size"
 void setTooltip(String tooltip)
          sets the Tooltip for this ListBox.
 void setWidth(String width)
          Sets the width of ListBox rendered in the HTML-Tag <select ... style="width:xxx;"
 
Methods inherited from class com.sapportals.htmlb.EventValidationComponent
getAllValidators, getClientEvent, getClientEventMap, getErrorText, getServerEvent, getServerEventMap, getValidator, isDisabled, isEnabled, isRequiresValidation, renderJavascriptInterface, setClientEvent, setDisabled, setEnabled, setErrorText, setRequiresValidation, setServerEvent, setValidator
 
Methods inherited from class com.sapportals.htmlb.Component
getEncodedIdForForm, getId, getParent, initFromShortId, initializeFromId, isJsObjectNeeded, preRender, render, renderAsString, requiresForm, setId, setJsObjectNeeded, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UI_ID

public static final String UI_ID
See Also:
Constant Field Values
Constructor Detail

ListBox

public ListBox(String name)
Creates a ListBox

Parameters:
name - the ListBox name
Method Detail

initFromPageContext

protected void initFromPageContext(IPageContext pc,
                                   String baseId)
internal use only. Components should override this method to analyse the parameters from the request object (via IPageContext) and set their internal data structures accordingly.

Overrides:
initFromPageContext in class Component
Parameters:
pc - the context, including the parameters
baseId - the prefix used for the component. (The result of a former RenderUtil.getIdForForm(rc, c);)

createDefaultModel

protected IListModel createDefaultModel()
Internal constructor for a default ListModel. protected so that subclasses can override

Returns:
a default model for the listbox

getModel

public IListModel getModel()
get the model underlying this ListBox

Returns:
the model

setModel

public void setModel(IListModel model)
set the model for this ListBox

Parameters:
model - the model

getSize

public int getSize()
Returns the size of ListBox rendered in the HTML-Tag <select size="size" ...>

Returns:
size

setSize

public void setSize(int size)
Sets the size of ListBox rendered in the HTML-Tag <select size="size" ...>

Parameters:
size - the size

getWidth

public String getWidth()
Returns the width of ListBox rendered in the HTML-Tag <select ... style="width:xxx;" ...>

Returns:
width

setWidth

public void setWidth(String width)
Sets the width of ListBox rendered in the HTML-Tag <select ... style="width:xxx;" ...>

Parameters:
width - the width

getMultiSelection

public String[] getMultiSelection()
Returns a list of selected items

Returns:
List of key of elements that are selected

addSelection

public void addSelection(String selection)
Add an item to the selected items list

Parameters:
selection - Key of the item to be added to the selected item list

removeSelection

public void removeSelection(String selection)
Removes an item from the selected items list

Parameters:
selection - Key of the item to be deleted from the selected item list

getSingleSelection

public String getSingleSelection()
Returns the selected items

Returns:
key of selected item

setSingleSelection

public void setSingleSelection(String selection)
Returns the selected items

Returns:
key of selected item

isSelected

public boolean isSelected(String key)
Checks if an item is in the selected item list

Parameters:
key - the key to check
Returns:
true, if item for this key is selected

getNameOfKeyColumn

public String getNameOfKeyColumn()
get the name of the column that contains the keys. Used if you use an underlying table in the model

Returns:
the name/identifier of the key column

setNameOfKeyColumn

public void setNameOfKeyColumn(String nameOfKeyColumn)
specify the name of the column that contains the keys. Used if you use an underlying table in the model

Parameters:
nameOfKeyColumn - the name/identifier of the key column

getNameOfValueColumn

public String getNameOfValueColumn()
get the name of the column that contains the visible texts. Used if you use an underlying table in the model

Returns:
the name/identifier of the key column

setNameOfValueColumn

public void setNameOfValueColumn(String nameOfValueColumn)
specify the name of the column that contains the visible texts. Used if you use an underlying table in the model

Parameters:
nameOfValueColumn - the name/identifier of the key column

getTooltip

public String getTooltip()
gets the Tooltip for this ListBox. Tooltips can not contain HTML coding.

Returns:
the tooltip text

setTooltip

public void setTooltip(String tooltip)
sets the Tooltip for this ListBox. Tooltips can not contain HTML coding.

Parameters:
tooltip - the tooltip text

getOnSelect

public String getOnSelect()
get the event identifier for a selection event.

Returns:
the identifier for the event

setOnSelect

public void setOnSelect(String onSelect)
set the event identifier for a selection event. A selection event is fired if the user changes the selection of the DropdownListBox

Parameters:
onSelect - the identifier for the event

getOnClientSelect

public String getOnClientSelect()
get the JavaScript fragment that is executed on the client side if the user changes the selection

Returns:
the JavaScript fragment.

setOnClientSelect

public void setOnClientSelect(String onClientSelect)
specify a clientside JavaScript that should be executed if the user changes the selection

Parameters:
onClientSelect - a JavaScript fragment.

getUI

public String getUI()
get a identification String for the renderer that is unique across all supported components. E.g. you could simply return the class name of the component class. The reason for using a separate method and not some internal reflection method is that you can more easily extend the functionality or your Component class without having to rewrite the view class.

Specified by:
getUI in class Component
Returns:
a unique identification string for this Component

addItem

public void addItem(String key,
                    String text)
Inserts a new item at the end of the list. You can't use this method, if you are using a JCo Table (see com.sapportals.htmlb.JCOListModel)

Parameters:
key - The key name of the item
text - The text displayed in the ListBox

getTextForKey

public String getTextForKey(String key)
Returns the text of a ListBox item

Parameters:
key - The key of ListBox item
Returns:
The text

getKeys

public Iterator getKeys()
get an Iterator for all keys contained in this DropdownListBox

Returns:
an Iterator for the keys

setLabeled

public void setLabeled(boolean isLabeled)
Description copied from interface: LabeledComponent
notify the component that a label has been assigned to it.

Specified by:
setLabeled in interface LabeledComponent

isLabeled

public boolean isLabeled()
Description copied from interface: LabeledComponent
checks if a label has been assigned to this component.

Specified by:
isLabeled in interface LabeledComponent


Copyright 2006 SAP AG Complete Copyright Notice