Wt: Wt::Form::WAbstractFormDelegate Class Reference

Wt 4.10.4

Loading...
Searching...
No Matches
Public Member Functions | List of all members
Wt::Form::WAbstractFormDelegate Class Referenceabstract
Dbo Forms (Wt::Form)

Abstract delegate class for creating form widgets. More...

`#include <Wt/Form/WAbstractFormDelegate.h>`

Inheritance diagram for Wt::Form::WAbstractFormDelegate:
[legend]

## Public Member Functions
| WAbstractFormDelegate ()
| Constructor.
virtual | ~WAbstractFormDelegate ()
| Destructor.
virtual std::unique_ptr< Wt::WWidget > | createFormWidget ()=0
| Create the widget to be used in the View.
virtual std::shared_ptr< Wt::WValidator > | createValidator ()
| Create the validator to be used by the Model.
virtual void | updateModelValue (Wt::WFormModel *model, Wt::WFormModel::Field field, Wt::WFormWidget *edit)
| Updates a value in the Model.
virtual bool | updateModelValue (Wt::WFormModel *model, Wt::WFormModel::Field field, Wt::WWidget *edit)
| Updates a value in the Model.
virtual void | updateViewValue (Wt::WFormModel *model, Wt::WFormModel::Field field, Wt::WFormWidget *edit)
| Updates a value in the View.
virtual bool | updateViewValue (Wt::WFormModel *model, Wt::WFormModel::Field field, Wt::WWidget *edit)
| Updates a value in the View.

## Detailed Description

Abstract delegate class for creating form widgets.

Form delegates will be automatically generated using Wt::Dbo's persist method. Depending on the data type used by the Dbo class, the form delegate will have a different behavior. For example: for WString objects the default widget in the view will be a WLineEdit.

Form delegates will be automatically generated when calling Dbo::FormView<C>::setFormModel(). This FormView also has the option to override the delegates that are generated by using Dbo::FormView<C>::setFormDelegate().

Form delegates will also create the corresponding WValidator and update the WFormModel and WTemplateFormView accordingly.

## Member Function Documentation

## ◆ createValidator()

virtual std::shared_ptr< Wt::WValidator > Wt::Form::WAbstractFormDelegate::createValidator | ( |  | ) |
| virtual

Create the validator to be used by the Model.

By default this returns a null pointer. When specializing this class, the user needs to override this method if they want to add validation to this field.

Reimplemented in Wt::Form::WFormDelegate< double, void >, Wt::Form::WFormDelegate< int, void >, Wt::Form::WFormDelegate< Wt::WDate, void >, and Wt::Form::WFormDelegate< Wt::WTime, void >.

## ◆ updateModelValue() [1/2]

virtual void Wt::Form::WAbstractFormDelegate::updateModelValue | ( | Wt::WFormModel * | model,
|  | Wt::WFormModel::Field | field,
|  | Wt::WFormWidget * | edit )
| virtual

Updates a value in the Model.

By default this sets the value in the model to the string returned by WFormWidget::valueText

The user should only override this method or the other updateModelValue method returning a boolean, depending on the type of widget that's returned by createFormWidget.

See also
  WTemplateFormView::updateModelValue()

Reimplemented in Wt::Form::WFormDelegate< bool, void >, Wt::Form::WFormDelegate< double, void >, Wt::Form::WFormDelegate< int, void >, Wt::Form::WFormDelegate< std::string, void >, Wt::Form::WFormDelegate< Wt::WDate, void >, Wt::Form::WFormDelegate< Wt::WDateTime, void >, and Wt::Form::WFormDelegate< Wt::WTime, void >.

## ◆ updateModelValue() [2/2]

virtual bool Wt::Form::WAbstractFormDelegate::updateModelValue | ( | Wt::WFormModel * | model,
|  | Wt::WFormModel::Field | field,
|  | Wt::WWidget * | edit )
| virtual

Updates a value in the Model.

By default this method returns false.

The user should only override this method or the other updateModelValue method, depending on the type of widget that's returned by createFormWidget.

See also
  WTemplateFormView::updateModelValue()

Reimplemented in Wt::Form::WFormDelegate< bool, void >, Wt::Form::WFormDelegate< double, void >, Wt::Form::WFormDelegate< int, void >, Wt::Form::WFormDelegate< std::string, void >, Wt::Form::WFormDelegate< Wt::WDate, void >, Wt::Form::WFormDelegate< Wt::WDateTime, void >, and Wt::Form::WFormDelegate< Wt::WTime, void >.

## ◆ updateViewValue() [1/2]

virtual void Wt::Form::WAbstractFormDelegate::updateViewValue | ( | Wt::WFormModel * | model,
|  | Wt::WFormModel::Field | field,
|  | Wt::WFormWidget * | edit )
| virtual

Updates a value in the View.

By default this uses WFormWidget::setValueText and WFormModel::value to update the widget

The user should only override this method or the other updateViewValue method returning a boolean, depending on the type of widget that's returned by createFormWidget.

See also
  WTemplateFormView::updateViewValue()

Reimplemented in Wt::Form::WFormDelegate< bool, void >, Wt::Form::WFormDelegate< double, void >, Wt::Form::WFormDelegate< int, void >, Wt::Form::WFormDelegate< Wt::WDate, void >, and Wt::Form::WFormDelegate< Wt::WTime, void >.

## ◆ updateViewValue() [2/2]

virtual bool Wt::Form::WAbstractFormDelegate::updateViewValue | ( | Wt::WFormModel * | model,
|  | Wt::WFormModel::Field | field,
|  | Wt::WWidget * | edit )
| virtual

Updates a value in the View.

By default this method returns false.

The user should only override this method or the other updateViewValue method, depending on the type of widget that's returned by createFormWidget.

See also
  WTemplateFormView::updateViewValue()

Reimplemented in Wt::Form::WFormDelegate< bool, void >, Wt::Form::WFormDelegate< double, void >, Wt::Form::WFormDelegate< int, void >, Wt::Form::WFormDelegate< Wt::WDate, void >, and Wt::Form::WFormDelegate< Wt::WTime, void >.