objectivehtml.htmlwidget
Class HtmlPushButton

java.lang.Object
  |
  +--objectivehtml.oms.OMSObject
        |
        +--objectivehtml.htmlwidget.HtmlElement
              |
              +--objectivehtml.htmlwidget.HtmlWidget
                    |
                    +--objectivehtml.htmlwidget.HtmlControlWidget
                          |
                          +--objectivehtml.htmlwidget.HtmlInput
                                |
                                +--objectivehtml.htmlwidget.HtmlPushButton

public class HtmlPushButton
extends HtmlInput

This class represents a html push button. i.e.

<input type="button|submit|reset" ... >

The widget provides users with a pressable button to trigger off an event. There are 3 button types, "button", "submit" and "reset". The "button" type is the generic version of this widget and can be used to trigger off a client-side action. When the button is clicked the "onclick" client-side event will be fired and will execute the scripting code set in the "onclick" attribute. The "submit" type provides a button that when clicked will submit the form data to server. The "reset" type provides a button that when clicked will clear all the form data back to its original values when the form was loaded.

The widget emits these signals:


Field Summary
static java.lang.String BUTTON
          This constant represents the "button" button-type
static java.lang.String RESET
          This constant represents the "reset" button-type
static java.lang.String SUBMIT
          This constant represents the "submit" button-type
 
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
HtmlPushButton(HtmlContainerWidget objParent, java.lang.String sName)
          Constructs an instance of HtmlPushButton.The default of button-type is "button".
 
Method Summary
 void clearClickedProxy()
          Clears the proxy object and proxy value if they exist.
 Signal clicked()
          This signal is emitted when the button is clicked.
 java.lang.String getButtonType()
          Returns the button-type of this push button.
 void handleProxyEvent(java.lang.String sProxyData)
          This method is used to determine whether the "clicked()" signal should be emitted when the "dataSubmitted(String)" signal is emitted from the proxy object.
 boolean isButtonTypeValid(java.lang.String sType)
          Checks the type attribute of this object.
 void setButtonType(java.lang.String sType)
          Sets the button-type for this push button.
 void setClickedProxy(HtmlHiddenInput objClickedProxy, java.lang.String sProxyValue)
          Sets the clicked proxy object for this HtmlPushButton.
 void updateData(javax.servlet.http.HttpServletRequest objRequest)
          Updates this object with the data submitted from the client.
 
Methods inherited from class objectivehtml.htmlwidget.HtmlInput
genStartTag, getText, getType, getValue, setAttribute, setBooleanAttribute, setText, setType, setValue, valueChanged
 
Methods inherited from class objectivehtml.htmlwidget.HtmlControlWidget
dataSubmitted, dataSubmitted, destroy, getName, getOnBlur, getOnChange, getOnFocus, getOnSelect, getSubmittedData, getSubmittedDataSet, getTabIndex, getUpdateOrder, isAutoEscape, isAutoUpdate, isDisabled, printHtml, printHtml, setAutoEscape, setAutoUpdate, 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, 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

BUTTON

public static final java.lang.String BUTTON
This constant represents the "button" button-type

SUBMIT

public static final java.lang.String SUBMIT
This constant represents the "submit" button-type

RESET

public static final java.lang.String RESET
This constant represents the "reset" button-type
Constructor Detail

HtmlPushButton

public HtmlPushButton(HtmlContainerWidget objParent,
                      java.lang.String sName)
               throws InvalidControlNameException,
                      InvalidParentWidgetException,
                      InvalidChildWidgetException
Constructs an instance of HtmlPushButton.The default of button-type is "button".
Parameters:
objParent - the parent of this widget
sName - the unique control name for the object
Throws:
InvalidControlNameException - if the control name is not valid
InvalidParentWidgetException - if the specified parent widget is not valid
InvalidChildWidgetException - if the parent widget does not accept this widget as a child
Method Detail

setClickedProxy

public void setClickedProxy(HtmlHiddenInput objClickedProxy,
                            java.lang.String sProxyValue)

Sets the clicked proxy object for this HtmlPushButton. The proxy is a HtmlHiddenInput object. When the objClickedProxy object emits the "dataSubmitted(String)" signal and the data is equal to sProxyValue then this object will emit the "clicked()" signal. This provides a way for the "clicked()" signal to be emitted even for a HtmlPushButton object with button-type "button". The actual code for this method is:

	m_objClickedProxy = objClickedProxy;
	m_sProxyValue = sProxyValue;

	try
	{
		connect(slot("handleProxyEvent(String)"), m_objClickedProxy.signal("dataSubmitted(String)"));
	} // end try
	catch (InvalidSlotException ise)
	{
		ise.printStackTrace();
	} // end catch ise
 
Parameters:
objClickedProxy - the proxy object
sProxyValue - the submitted data value that the proxy is bound to
See Also:
clearClickedProxy(), handleProxyEvent(String)

handleProxyEvent

public void handleProxyEvent(java.lang.String sProxyData)

This method is used to determine whether the "clicked()" signal should be emitted when the "dataSubmitted(String)" signal is emitted from the proxy object.

Parameters:
sProxyData - the data submitted by the proxy
See Also:
setClickedProxy(HtmlHiddenInput, String)

clearClickedProxy

public void clearClickedProxy()

Clears the proxy object and proxy value if they exist.

See Also:
setClickedProxy(HtmlHiddenInput, String)

setButtonType

public void setButtonType(java.lang.String sType)
                   throws InvalidButtonTypeException

Sets the button-type for this push button. The 3 allowed values are "button" (default), "submit" and "reset". Use the constants BUTTON, SUBMIT and RESET.

The "button" type is the generic version of this widget and can be used to trigger off a client-side action. When the button is clicked the "onclick" client-side event will be fired and will execute the scripting code set in the "onclick" attribute. The "submit" type provides a button that when clicked will submit the form data to server. The "reset" type provides a button that when clicked will clear all the form data back to its original values when the form was loaded.

The html attribute it sets is "button".

If null is specified the attribute is cleared.

Parameters:
sType - the button for this element
See Also:
HtmlWidget.setOnClick(String), HtmlInput.setAttribute(String, String), getButtonType(), BUTTON, SUBMIT, RESET

getButtonType

public java.lang.String getButtonType()
Returns the button-type of this push button.
Returns:
the button-type for this element, null is returned if the attribute is not set
See Also:
setButtonType(String), HtmlElement.getAttribute(String)

isButtonTypeValid

public boolean isButtonTypeValid(java.lang.String sType)
Checks the type attribute of this object. There are 3 valid button types "button", "submit" or "reset" (case-insensitive).
Parameters:
sType - the type for this html element
Returns:
true if the button-type is valid, false otherwise

updateData

public void updateData(javax.servlet.http.HttpServletRequest objRequest)

Updates this object with the data submitted from the client. If the submitted data is not null the value is updated.

The object will only be updated if the auto-update is on and if the object is visible and not disabled.

Overrides:
updateData in class HtmlControlWidget
Parameters:
objRequest - the request object that contains the user submitted data
See Also:
HtmlInput.getValue(), HtmlWidget.isVisible(), HtmlControlWidget.isDisabled(), HtmlControlWidget.isAutoUpdate(), HtmlControlWidget.getSubmittedData(HttpServletRequest)

clicked

public Signal clicked()
This signal is emitted when the button is clicked. It is fired off when updateData(HttpServletRequest) method is called and the user has clicked this button. This signal only works for the button-type "submit". The limitation of this signal only working button-type "submit" can be overcome by using a proxy object. See the setClickedProxy(HtmlHiddenInput,String) method for more details.
Returns:
the signal object
See Also:
setClickedProxy(HtmlHiddenInput,String)