|
|||||||||
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
This is the base class of all control widgets. Control widgets are classes that can trigger action events and accept user inputs. Control widgets do not have any children.
All control widgets must have a unique name. The name is used to uniquely identify the widget in the html form and is required to correctly bind the submitted data to the object. The only exception is the HtmlRadioButton object. When HtmlRadioButton objects have the same control name they are grouped together.
If auto-escape is turned on (default) then all textual data will be escaped before being written by the printHtml(output) methods. Special html characters are escaped using the HtmlUtils.htmlSpecialChars(String) method.
If auto-update is turned on (default) then when updateData(request) is called the object will be updated with the submitted user data.
The destroy() method of a HtmlControlWidget object will also free up its control name to be used again by another object.
setAutoUpdate(boolean)
,
setAutoEscape(boolean)
,
updateData(HttpServletRequest)
,
HtmlElement.printHtml(JspWriter)
,
HtmlElement.printHtml(PrintWriter)
,
HtmlRadioButton
,
HtmlUtils.htmlSpecialChars(String)
Field Summary | |
protected boolean |
m_bAutoEscape
Indicates whether auto-escape is enabled or not |
protected boolean |
m_bAutoUpdate
Indicates whether auto-update is enabled or not |
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 | |
HtmlControlWidget(HtmlContainerWidget objParent,
java.lang.String sName,
boolean bSkipNameValidation)
Constructs an instance of the HtmlControlWidget object with the specified control name. |
Method Summary | |
Signal |
dataSubmitted(java.lang.String sData)
This signal is emitted when data is submitted by the user. |
Signal |
dataSubmitted(java.lang.String[] asData)
This signal is emitted when data is submitted by the user. |
void |
destroy()
Deletes itself and frees the control name be used again. |
java.lang.String |
getName()
Returns the control name of for this control widget. |
java.lang.String |
getOnBlur()
Returns the onblur event of this object. |
java.lang.String |
getOnChange()
Returns the onchange event of this object. |
java.lang.String |
getOnFocus()
Returns the onfocus event of this object. |
java.lang.String |
getOnSelect()
Returns the onselect event of this object. |
java.lang.String |
getSubmittedData(javax.servlet.http.HttpServletRequest objRequest)
Retrieves the client submitted data associated with this widget. |
java.lang.String[] |
getSubmittedDataSet(javax.servlet.http.HttpServletRequest objRequest)
Retrieves the client submitted data-set associated with this widget. |
java.lang.String |
getTabIndex()
Returns the tab index of this object. |
int |
getUpdateOrder()
Returns the update order of this control widget |
boolean |
isAutoEscape()
Returns whether the auto-escape feature is on or not. |
boolean |
isAutoUpdate()
Returns whether the auto-update feature is on or not. |
boolean |
isDisabled()
Returns whether this object is disabled or enabled. |
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 |
setAttribute(java.lang.String sName,
java.lang.String sValue)
Sets an attribute of this object. |
void |
setAutoEscape(boolean bAutoEscape)
Sets the auto-escape feature to be either on (default) or off. |
void |
setAutoUpdate(boolean bAutoUpdate)
Sets the auto-update feature to be either on (default) or off. |
void |
setBooleanAttribute(java.lang.String sName,
boolean bIsOn)
Sets a boolean-attribute of this object. |
void |
setDisabled(boolean bDisabled)
Sets the HtmlControlWidget object to be either disabled or enabled. |
void |
setOnBlur(java.lang.String sOnBlur)
Sets the onblur event of this object. |
void |
setOnChange(java.lang.String sOnChange)
Sets the onchange event of this object. |
void |
setOnFocus(java.lang.String sOnFocus)
Sets the onfocus event of this object. |
void |
setOnSelect(java.lang.String sOnSelect)
Sets the onselect event of this object. |
void |
setTabIndex(java.lang.String sTabIndex)
Sets the tab index of this widget. |
void |
setUpdateOrder(int nUpdateOrder)
Sets the update order of this control widget. |
void |
setVisible(boolean bVisible)
Overrides the default protected method to be public. |
abstract void |
updateData(javax.servlet.http.HttpServletRequest objRequest)
Updates the internal state of this control widget with the client submitted data. |
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 |
Field Detail |
protected boolean m_bAutoUpdate
protected boolean m_bAutoEscape
Constructor Detail |
public HtmlControlWidget(HtmlContainerWidget objParent, java.lang.String sName, boolean bSkipNameValidation) throws InvalidControlNameException, InvalidParentWidgetException, InvalidChildWidgetException
objParent
- the parent of this widgetsName
- the unique control namebSkipNameValidation
- true if name validation can be skipped, only true for HtmlRadioButtonInvalidControlNameException
- if the control name is not valid or uniqueInvalidParentWidgetException
- if the specified parent widget is not validInvalidChildWidgetException
- if the parent widget does not accept this widget as a childMethod Detail |
public void setVisible(boolean bVisible)
setVisible
in class HtmlWidget
bVisible
- true to be visible, false to be invisibleHtmlWidget.setVisible(boolean)
public void setAutoUpdate(boolean bAutoUpdate)
Sets the auto-update feature to be either on (default) or off.
If auto-update is set as true then when the form is submitted from the client the value of the control widget will be automatically updated when updateData(HttpServletRequest) is called.
If auto-update is set as false then the value of the control widget needs to be manually updated by the programmer. Use this with getSubmittedData(HttpServletRequest) if you want auto-update off.
bAutoUpdate
- true if you want auto-update on (default), false otherwiseupdateData(HttpServletRequest)
,
getSubmittedData(HttpServletRequest)
,
isAutoUpdate()
public boolean isAutoUpdate()
setAutoUpdate(boolean)
public void setAutoEscape(boolean bAutoEscape)
bAutoEscape
- true if you want auto-escape on (default), false otherwiseHtmlUtils.htmlSpecialChars(String)
,
isAutoEscape()
public boolean isAutoEscape()
setAutoEscape(boolean)
public void setUpdateOrder(int nUpdateOrder)
Sets the update order of this control widget. The update order is used by the HtmlForm object when it refreshes the state of the form objects with the updateData(HttpServletRequest) method. The order these objects are updated with the submitted data is done according to this order. The control widgets with lowest update order values are updated first (0 being the lowest). If 2 or more control widgets have the same update order then they are updated accordingly to their natural order. The natural order is simply starting from the top-left of the form, going right first, then downwards.
The default update order is 0 for all control widgets.
If a negative number is given the update order is modified to be 0.
nUpdateOrder
- the update ordergetUpdateOrder()
,
HtmlForm.updateData(HttpServletRequest)
public int getUpdateOrder()
setUpdateOrder(int)
public abstract void updateData(javax.servlet.http.HttpServletRequest objRequest)
objRequest
- the current request object with the client submitted datapublic java.lang.String getSubmittedData(javax.servlet.http.HttpServletRequest objRequest)
Retrieves the client submitted data associated with this widget. Data from the client is bound to this object via its control name.
Normally you will not have to explicity use this method unless you are not using the auto-update feature.
objRequest
- the current request object with the client submitted datasetAutoUpdate(boolean)
,
getName()
,
getSubmittedDataSet(HttpServletRequest)
public java.lang.String[] getSubmittedDataSet(javax.servlet.http.HttpServletRequest objRequest)
Retrieves the client submitted data-set associated with this widget. Data from the client is bound to this object via its control name.
Normally you will not have to explicity use this method unless you are not using the auto-update feature.
objRequest
- the current request object with the client submitted datasetAutoUpdate(boolean)
,
getName()
,
getSubmittedData(HttpServletRequest)
public java.lang.String getName()
public void setDisabled(boolean bDisabled)
Sets the HtmlControlWidget object to be either disabled or enabled. When a HtmlControlWidget object is disabled, the user will not be able to interact with the object. This is normally useful when you wish to display some read-only data to the user. Note however, not all browsers correctly support this feature. Netscape 4.x does not support this feature, IE 4.x and higher and Netscape 6.x does support this feature.
When a control widget is disabled, its internal state will not be updated by the updateData(HttpServletRequest) method.
The html attribute that it sets is "disabled".
bDisabled
- true indicates disabled, false indicates enabledupdateData(HttpServletRequest)
,
isDisabled()
public boolean isDisabled()
setDisabled(boolean)
public void setTabIndex(java.lang.String sTabIndex)
Sets the tab index of this widget. If this control widget is in focus, then pressing tab will move the focus to the control widget that has the lowest tax index but that is greater than the tax index of itself. Use this attribute to organise the tab sequence of your form.
The html attribute that it sets is "tabindex".
sTabIndex
- the tab index for this html element
if null is specified then this attribute
will be clearedgetTabIndex()
public java.lang.String getTabIndex()
setTabIndex(String)
public void setOnFocus(java.lang.String sOnFocus)
Sets the onfocus event of this object.
The html attribute it sets is "onfocus".
sOnFocus
- the onfocus event for this html element,
if null is specified then this attribute
will be clearedgetOnFocus()
public java.lang.String getOnFocus()
setOnFocus(String)
public void setOnBlur(java.lang.String sOnBlur)
Sets the onblur event of this object.
The html attribute it sets is "onblur".
sOnBlur
- the onblur event for this html element
if null is specified then this attribute
will be clearedgetOnBlur()
public java.lang.String getOnBlur()
Returns the onblur event of this object.
The html attribute it gets is "onblur".
setOnBlur(String)
public void setOnSelect(java.lang.String sOnSelect)
Sets the onselect event of this object.
The html attribute it sets is "onselect".
sOnSelect
- the onselect event for this html element
if null is specified then this attribute
will be clearedgetOnSelect()
public java.lang.String getOnSelect()
Returns the onselect event of this object.
The html attribute it gets is "onselect".
setOnSelect(String)
public void setOnChange(java.lang.String sOnChange)
Sets the onchange event of this object.
The html attribute it sets is "onchange".
sOnChange
- the onchange event for this html element
if null is specified then this attribute
will be clearedgetOnChange()
public java.lang.String getOnChange()
Returns the onchange event of this object.
The html attribute it gets is "onchange".
setOnChange(String)
public void setAttribute(java.lang.String sName, java.lang.String sValue) throws InvalidAttributeException
Sets an attribute of this object.
This overrides the parent version of this method to block the "name" attribute being modified. If you attempt to modify the "name" attribute then the InvalidAttributeException is thrown.
setAttribute
in class HtmlElement
sName
- the name of the attributesValue
- the value of the attribute, if null is specified
then the attribute will be clearedHtmlElement.setAttribute(String, String)
,
setBooleanAttribute(String, boolean)
public void setBooleanAttribute(java.lang.String sName, boolean bIsOn) throws InvalidAttributeException
Sets a boolean-attribute of this object.
This overrides the parent version of this method to block the "name" attribute being modified. If you attempt to modify the "name" attribute then the InvalidAttributeException is thrown.
setBooleanAttribute
in class HtmlElement
sName
- the name of the attributebIsOn
- true if attribute should be set, if false
is specified then the attribute is clearedHtmlElement.setBooleanAttribute(String, boolean)
,
setAttribute(String, String)
public void destroy()
destroy
in class HtmlWidget
objectivehtml.htmlwidget.HtmlWidget
HtmlWidget.isDestroyed()
public void printHtml(java.io.PrintWriter objWriter, int nOutputType) throws java.io.IOException
printHtml
in class HtmlElement
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 HtmlElement
objWriter
- the output stream for a Jsp pagenOutputType
- the output typejava.io.IOException
- if it cannot write the outputpublic Signal dataSubmitted(java.lang.String sData)
sData
- the new submitted dataHtmlWidget.isVisible()
,
isDisabled()
,
HtmlTextBox.isReadOnly()
,
HtmlTextArea.isReadOnly()
,
dataSubmitted(String[])
public Signal dataSubmitted(java.lang.String[] asData)
This signal is emitted when data is submitted by the user. The signal is emitted when the updateData(HttpServletRequest) method is called and is emitted just before the state of each control widget is updated with the new submitted data. The signal is only emitted when the control widget is visible, not disabled and not in read-only mode. The signal is emitted regardless of whether auto-update is on or off.
This overloaded version should be used when control widgets are expecting more than one submitted value (e.g. HtmlListBox). If there is only one submitted value then asData will be an array of length 1.
This method also provides a convenient way for data to be filtered or cleaned up before being used to update the state of a control widget. The array of String objects (asData) emitted by the signal is the same array that will be used by each control widget to update their internal state. For e.g. you may need to run an encode(String) method on all submitted data. This can be done like this:
public void encode(String[] asData) { if (asData != null) { for (int i=0; i<asData.length; i++) { asData[i] = encode(asData[i]); } } }
Simply connect this slot method to the "dataSubmitted(String[])" signal of all the control widgets that you need to encode.
asData
- the array of new submitted dataHtmlWidget.isVisible()
,
isDisabled()
,
HtmlTextBox.isReadOnly()
,
HtmlTextArea.isReadOnly()
,
dataSubmitted(String)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |