Public Member Functions | Protected Member Functions

Wt::WFormWidget Class Reference

An abstract widget that corresponds to an HTML form element. More...

#include <Wt/WFormWidget>

Inherits Wt::WInteractWidget.

Inherited by Wt::WAbstractToggleButton, Wt::WComboBox, Wt::WLineEdit, Wt::WPushButton, and Wt::WTextArea.

List of all members.

Public Member Functions

 WFormWidget (WContainerWidget *parent=0)
 Creates a WFormWidget with an optional parent.
 ~WFormWidget ()
 Destructor.
WLabellabel () const
 Returns the label associated with this widget.
virtual void setHidden (bool hidden)
 Sets the hidden state of this widget.
void setValidator (WValidator *validator)
 Sets a validator for this field.
WValidatorvalidator () const
 Returns the validator.
virtual WValidator::State validate ()
 Validates the field.
void setEnabled (bool enabled)
 Sets whether the widget is enabled.
void setFocus ()
 Gives focus to this widget.
void setReadOnly (bool readOnly)
 Sets the element read-only.
bool isReadOnly () const
 Returns whether the form element is read-only.
void setEmptyText (const WString &emptyText)
 Sets the empty text to be shown when the field is empty.
const WStringemptyText ()
 Returns the empty text to be shown when the field is empty.
EventSignalchanged ()
 Signal emitted when the value was changed.
EventSignalselected ()
 Signal emitted when ??
EventSignalblurred ()
 Signal emitted when the widget lost focus.
EventSignalfocussed ()
 Signal emitted when the widget recieved focus.

Protected Member Functions

virtual void enableAjax ()
 Progresses to an Ajax-enabled widget.
virtual WStatelessSlot * getStateless (Method method)
 On-demand stateless slot implementation.
virtual void propagateSetEnabled (bool enabled)
 Propagates that a widget was enabled or disabled through children.

Detailed Description

An abstract widget that corresponds to an HTML form element.

A WFormWidget may receive focus, can be disabled, and can have a label that acts as proxy for getting focus. It provides signals which reflect changes to its value, or changes to its focus.

Form widgets also have built-in support for validation, using setValidator(WValidator *). If the validator provide client-side validation, then an invalid validation state is reflected using the style class "Wt-invalid". All validators provided by Wt implement client-side validation.

On the server-side, use validate() method to validate the content using a validator previously set.


Constructor & Destructor Documentation

Wt::WFormWidget::~WFormWidget (  ) 

Destructor.

If a label was associated with the widget, its buddy is reset to 0.


Member Function Documentation

const WString& Wt::WFormWidget::emptyText (  )  [inline]

Returns the empty text to be shown when the field is empty.

See also:
setEmptyText()
void Wt::WFormWidget::enableAjax (  )  [protected, virtual]

Progresses to an Ajax-enabled widget.

This method is called when the progressive bootstrap method is used, and support for AJAX has been detected. The default behavior will upgrade the widget's event handling to use AJAX instead of full page reloads, and propagate the call to its children.

You may want to reimplement this method if you want to make changes to widget when AJAX is enabled. You should always call the base implementation.

See also:
WApplication::enableAjax()

Reimplemented from Wt::WWebWidget.

WStatelessSlot * Wt::WFormWidget::getStateless ( Method  method  )  [protected, virtual]

On-demand stateless slot implementation.

This method returns a stateless slot implementation for the given method. To avoid the cost of declaring methods to be stateless when they are not used, you may reimplement this method to provide a stateless implementation for a method only when the method is involved in a slot connection.

Use implementStateless() to provide a stateless implementation of the given method, or return the base class implementation otherwise.

Reimplemented from Wt::WWidget.

Reimplemented in Wt::WAbstractToggleButton.

bool Wt::WFormWidget::isReadOnly (  )  const

Returns whether the form element is read-only.

See also:
setReadOnly()
WLabel* Wt::WFormWidget::label (  )  const [inline]

Returns the label associated with this widget.

Returns the label (if there is one) that acts as a proxy for this widget.

See also:
WLabel::setBuddy(WFormWidget *)
void Wt::WFormWidget::propagateSetEnabled ( bool  enabled  )  [protected, virtual]

Propagates that a widget was enabled or disabled through children.

When enabling or disabling a widget, you usually also want to disable contained children. This method is called by setDisabled() to propagate its state to all children.

You may want to reimplement this method if they wish to render differently when a widget is disabled. The default implementation will propagate the signal to all children.

Reimplemented from Wt::WWebWidget.

void Wt::WFormWidget::setEmptyText ( const WString emptyText  ) 

Sets the empty text to be shown when the field is empty.

See also:
emptyText()
void Wt::WFormWidget::setEnabled ( bool  enabled  ) 

Sets whether the widget is enabled.

A widget that is disabled cannot receive focus or user interaction.

This is the opposite of setDisabled().

void Wt::WFormWidget::setFocus (  ) 

Gives focus to this widget.

Giving focus to an input element only works when JavaScript is enabled.

void Wt::WFormWidget::setHidden ( bool  hidden  )  [virtual]

Sets the hidden state of this widget.

If the widget has a label, it is hidden and shown together with this widget.

Reimplemented from Wt::WWebWidget.

void Wt::WFormWidget::setReadOnly ( bool  readOnly  ) 

Sets the element read-only.

A read-only form element cannot be edited, but the contents can still be selected.

By default, a form element area is not read-only.

See also:
setEnabled()
void Wt::WFormWidget::setValidator ( WValidator validator  ) 

Sets a validator for this field.

The validator is used to validate the current input.

If the validator has no parent yet, then ownership is transferred to the form field, and thus the validator will be deleted together with the form field.

The default value is 0.

See also:
validate()

Generated on Mon Nov 29 2010 08:03:18 for Wt by doxygen 1.7.1