|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--objectivehtml.oms.OMSObject | +--objectivehtml.htmlwidget.HtmlElement | +--objectivehtml.htmlwidget.HtmlWidget | +--objectivehtml.htmlwidget.HtmlControlWidget | +--objectivehtml.htmlwidget.HtmlListBox
This class represents combobox or list box. i.e.
<select> <option value="1">Apples</option> <option value="2">Bananas</option> <option value="3">Oranges</option> </select>
The widget allows users to select one or multiple options from a list of options. If the list box has a "size" of one then the widget will be rendered as a drop-down list and the user must click on the drop-down to see the list of available options. If the "size" is greater than one then the widget will be rendered as a list box and users can see a number of options at one time and can scroll through the options. If the "multiple" attribute is set then the user may select one or more options, otherwise they can only choose one.
This widget contains a list of HtmlOptionItem objects internally. These objects represent each option that is available in this list box. An option item has 2 components, its value and option text (description). The value is what is used internally by the form to identify the option item, where as the option text is what is displayed to the client. The value of each option item must be unique for the object to correctly identify the selected values of the list box.
The widget emits these signals:
HtmlOptionItem
Fields inherited from class objectivehtml.htmlwidget.HtmlControlWidget |
m_bAutoEscape, m_bAutoUpdate |
Fields inherited from class objectivehtml.htmlwidget.HtmlWidget |
m_bDestroyed, m_bVisible, m_objHtmlForm, m_objParentWidget |
Fields inherited from class objectivehtml.htmlwidget.HtmlElement |
m_hmAttributes, m_sEndTag, m_sQuoteType, m_sStartTag |
Constructor Summary | |
HtmlListBox(HtmlContainerWidget objParent,
java.lang.String sName)
Constructs an instance of the HtmlListBox with the parent objParent and control name sName. |
Method Summary | |
void |
addOption(java.lang.String sValue,
java.lang.String sOptionText)
Adds a (value, option) pair to the list box. |
void |
clearOptions()
Clears all the options of the list box. |
void |
clearSelections()
Clears all the selections of this list box. |
int |
getNumberOfOptions()
Returns the number of options for this list box. |
HtmlOptionItem |
getOptionItem(int nIndex)
Returns the HtmlOptionItem object representing the option at the specified index nIndex. |
int |
getOptionItemIndex(HtmlOptionItem objOptionItem)
Returns the index of the given HtmlOptionItem object. |
int |
getSelectedIndex()
Returns the index of the first selected item or -1 if no item is selected. |
int[] |
getSelectedIndicies()
Returns an array of the indicies of the currently selected options |
java.lang.String |
getSelectedValue()
Returns the value of the first selected item or null if no item is selected. |
java.lang.String[] |
getSelectedValues()
Returns an array of the values of the currently selected options |
java.lang.String |
getSize()
Returns the size of this list box. |
boolean |
isMultiple()
Returns whether the list box allows multiple selections. |
boolean |
isSelected(int nIndex)
Indicates if an option item has been selected. |
Signal |
optionSelected(int nOptionIndex)
This signal is emitted when an option is selected. |
Signal |
optionSelected(java.lang.String sOptionValue)
This signal is emitted when an option is selected. |
void |
printHtml(javax.servlet.jsp.JspWriter objWriter,
int nOutputType)
Prints the html that represents this object to the output stream. |
void |
printHtml(java.io.PrintWriter objWriter,
int nOutputType)
Prints the html that represents this object to the output stream. |
void |
removeOption(int nIndex)
Removes an option from the list box at the specified index nIndex. |
Signal |
selectionUpdated(int[] anNewSelectedIndicies,
int[] anOldSelectedIndicies)
This signal is emitted when the updateData(HttpServletRequest) method is called on this object and selections have changed. |
Signal |
selectionUpdated(java.lang.String[] asNewValues,
java.lang.String[] asOldValues)
This signal is emitted when the updateData(HttpServletRequest) method is called on this object and selections have changed. |
void |
setAutoEscape(boolean bAutoEscape)
Sets the auto-escape feature to be either on (default) or off. |
void |
setMultiple(boolean bMultiple)
Sets the list box to either accept multiple selections or a single selection. |
void |
setSelected(int nIndex,
boolean bChecked)
Sets the specified option item to be checked or unchecked. |
void |
setSelected(java.lang.String sOptionValue,
boolean bChecked)
Sets the first option item with the value sOptionValue to be checked or unchecked. |
void |
setSize(java.lang.String sSize)
Sets the size for this list box. |
void |
updateData(javax.servlet.http.HttpServletRequest objRequest)
Updates this object with the data submitted from the client. |
Methods inherited from class objectivehtml.htmlwidget.HtmlControlWidget |
dataSubmitted, dataSubmitted, destroy, getName, getOnBlur, getOnChange, getOnFocus, getOnSelect, getSubmittedData, getSubmittedDataSet, getTabIndex, getUpdateOrder, isAutoEscape, isAutoUpdate, isDisabled, setAttribute, setAutoUpdate, setBooleanAttribute, setDisabled, setOnBlur, setOnChange, setOnFocus, setOnSelect, setTabIndex, setUpdateOrder, setVisible |
Methods inherited from class objectivehtml.htmlwidget.HtmlWidget |
changeParent, changeParent, getClassAttribute, getHtmlForm, getID, getOnClick, getOnDblClick, getOnKeyDown, getOnKeyPress, getOnKeyUp, getOnMouseDown, getOnMouseMove, getOnMouseOut, getOnMouseOver, getOnMouseUp, getParent, getStyle, isDestroyed, isVisible, setClassAttribute, setID, setOnClick, setOnDblClick, setOnKeyDown, setOnKeyPress, setOnKeyUp, setOnMouseDown, setOnMouseMove, setOnMouseOut, setOnMouseOver, setOnMouseUp, setStyle |
Methods inherited from class objectivehtml.htmlwidget.HtmlElement |
genEndTag, genStartTag, genStartTag, getAttribute, getAttributes, getBooleanAttribute, getQuoteType, printHtml, printHtml, printHtml, printHtml, printHtml, printHtml, setQuoteType, toString, toString |
Methods inherited from class objectivehtml.oms.OMSObject |
compareClasses, connect, disconnect, emit, isAlive, setAlive, signal, slot, slot |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public HtmlListBox(HtmlContainerWidget objParent, java.lang.String sName) throws InvalidControlNameException, InvalidParentWidgetException, InvalidChildWidgetException
objParent
- the parent of this widgetsName
- the unique control name for the objectInvalidControlNameException
- if the control name is not validInvalidParentWidgetException
- if the specified parent widget is not validInvalidChildWidgetException
- if the parent widget does not accept this widget as a childMethod Detail |
public void setAutoEscape(boolean bAutoEscape)
setAutoEscape
in class HtmlControlWidget
bAutoEscape
- true if you want auto-escape on, false otherwisegetOptionItem(int)
,
HtmlUtils.htmlSpecialChars(String)
,
HtmlOptionItem
public void addOption(java.lang.String sValue, java.lang.String sOptionText)
sValue
- the value for the new optionsOptionText
- the text part of the new optiongetOptionItem(int)
,
removeOption(int)
,
HtmlOptionItem
public void removeOption(int nIndex)
nIndex
- the index position of the option to be removedaddOption(String, String)
,
getOptionItem(int)
public int getNumberOfOptions()
public HtmlOptionItem getOptionItem(int nIndex)
nIndex
- the index position of the optionaddOption(String, String)
,
getNumberOfOptions()
,
HtmlOptionItem
public int getOptionItemIndex(HtmlOptionItem objOptionItem)
objOptionItem
- the option itemHtmlOptionItem
public void setMultiple(boolean bMultiple)
Sets the list box to either accept multiple selections or a single selection. If true is specified then the list box will allow multiple selections, if false is specified then only one selection can be made.
The html attribute it sets is "multiple".
If false is specified the attribute is cleared.
bMultiple
- true if you want multiple selections, false for only oneHtmlControlWidget.setBooleanAttribute(String, boolean)
,
isMultiple()
public boolean isMultiple()
HtmlElement.getBooleanAttribute(String)
,
setMultiple(boolean)
public void clearSelections()
Clears all the selections of this list box.
setSelected(int, boolean)
,
isSelected(int)
public void clearOptions()
Clears all the options of the list box.
addOption(String, String)
public int getSelectedIndex()
getSelectedValue()
,
getSelectedIndicies()
public java.lang.String getSelectedValue()
getSelectedIndex()
,
getSelectedValues()
public void setSelected(int nIndex, boolean bChecked)
Sets the specified option item to be checked or unchecked.
If the list box does not have multiple selections enabled then this method will clear all selections before selecting the new option.
nIndex
- the index of the option to check/uncheckbChecked
- true if you want the option checked, false otherwsegetOptionItem(int)
,
HtmlOptionItem.setSelected(boolean)
,
clearSelections()
,
isSelected(int)
,
isMultiple()
,
setSelected(String,boolean)
public void setSelected(java.lang.String sOptionValue, boolean bChecked)
Sets the first option item with the value sOptionValue to be checked or unchecked.
If the list box does not have multiple selections enabled then this method will clear all selections before selecting the new option.
sOptionValue
- the value of the option to check/uncheckbChecked
- true if you want the option checked, false otherwsegetOptionItem(int)
,
HtmlOptionItem.setSelected(boolean)
,
clearSelections()
,
isSelected(int)
,
isMultiple()
,
setSelected(int,boolean)
public boolean isSelected(int nIndex)
nIndex
- the index of the option item you want to querysetSelected(int, boolean)
public java.lang.String getSize()
setSize(String)
,
HtmlElement.getAttribute(String)
public void setSize(java.lang.String sSize)
Sets the size for this list box. If the size is not set (default) or is set to 1 then the object is rendered as a combo-box. If the size is greater than 1 then the object is rendered as a list box and shows "size" number of option items at any one time.
The html attribute it sets is "size".
If null is specified the attribute is cleared.
sSize
- the size for this elementHtmlControlWidget.setAttribute(String, String)
,
getSize()
public void updateData(javax.servlet.http.HttpServletRequest objRequest)
Updates this object with the data submitted from the client. If the submitted data for this list box equals any of the values set in the HtmlOptionItem objects then these options will become checked. If the submitted data does not match the value set in a HtmlOptionItem object then it will become unchecked.
The object will only be updated if the auto-update is on and if the object is visible and not disabled.
updateData
in class HtmlControlWidget
objRequest
- the request object that contains the user submitted dataHtmlOptionItem.getValue()
,
HtmlWidget.isVisible()
,
HtmlControlWidget.isDisabled()
,
HtmlControlWidget.isAutoUpdate()
,
HtmlControlWidget.getSubmittedDataSet(HttpServletRequest)
public int[] getSelectedIndicies()
getSelectedIndex()
,
getSelectedValues()
public java.lang.String[] getSelectedValues()
getSelectedValues()
public void printHtml(java.io.PrintWriter objWriter, int nOutputType) throws java.io.IOException
printHtml
in class HtmlControlWidget
objWriter
- the output stream for a Servlet objectnOutputType
- the output typejava.io.IOException
- if it cannot write the outputpublic void printHtml(javax.servlet.jsp.JspWriter objWriter, int nOutputType) throws java.io.IOException
printHtml
in class HtmlControlWidget
objWriter
- the output stream for a Jsp pagenOutputType
- the output typejava.io.IOException
- if it cannot write the outputpublic Signal optionSelected(java.lang.String sOptionValue)
This signal is emitted when an option is selected. The signal is only emitted if the option was previously unselected.
If the list box allows multiple selections then when updateData(HttpServletRequest) is called each option selection will fire off this signal.
sOptionValue
- the value of the item selectedoptionSelected(int)
,
updateData(HttpServletRequest)
public Signal selectionUpdated(java.lang.String[] asNewValues, java.lang.String[] asOldValues)
This signal is emitted when the updateData(HttpServletRequest) method is called on this object and selections have changed.
asNewValues
- the values of the new selected itemsasOldValues
- the values of the old selected items (before update)selectionUpdated(int[], int[])
public Signal optionSelected(int nOptionIndex)
This signal is emitted when an option is selected. The signal is only emitted if the option was previously unselected.
If the list box allows multiple selections then when updateData(HttpServletRequest) is called each option selection will fire off this signal.
nOptionIndex
- the index of the item selectedoptionSelected(String)
,
updateData(HttpServletRequest)
public Signal selectionUpdated(int[] anNewSelectedIndicies, int[] anOldSelectedIndicies)
This signal is emitted when the updateData(HttpServletRequest) method is called on this object and selections have changed.
anNewSelectedIndicies
- the indicies of the new selected itemsanOldSelectedIndicies
- the indicies of the old selected items (before update)selectionUpdated(String[], String[])
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |