Wt  4.6.1
Public Member Functions | List of all members
Wt::Form::WAbstractFormDelegate Class Referenceabstract

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

#include <Wt/Form/WAbstractFormDelegate.h>

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

Public Member Functions

 WAbstractFormDelegate ()
 Create a form delegate.
 
virtual std::unique_ptr< Wt::WWidgetcreateFormWidget ()=0
 Create the widget to be used in the View.
 
virtual std::shared_ptr< Wt::WValidatorcreateValidator ()
 Create the validator to be used by the Model. More...
 
virtual void updateModelValue (Wt::WFormModel *model, Wt::WFormModel::Field field, Wt::WFormWidget *edit)
 Updates a value in the Model. More...
 
virtual bool updateModelValue (Wt::WFormModel *model, Wt::WFormModel::Field field, Wt::WWidget *edit)
 Updates a value in the Model. More...
 
virtual void updateViewValue (Wt::WFormModel *model, Wt::WFormModel::Field field, Wt::WFormWidget *edit)
 Updates a value in the View. More...
 
virtual bool updateViewValue (Wt::WFormModel *model, Wt::WFormModel::Field field, Wt::WWidget *edit)
 Updates a value in the View. More...
 

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()

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::WTime, void >, and Wt::Form::WFormDelegate< Wt::WDate, void >.

◆ updateModelValue() [1/2]

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< double, void >, Wt::Form::WFormDelegate< int, void >, Wt::Form::WFormDelegate< bool, void >, Wt::Form::WFormDelegate< Wt::WDateTime, void >, Wt::Form::WFormDelegate< Wt::WTime, void >, Wt::Form::WFormDelegate< Wt::WDate, void >, and Wt::Form::WFormDelegate< std::string, void >.

◆ updateModelValue() [2/2]

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()

◆ updateViewValue() [1/2]

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< double, void >, Wt::Form::WFormDelegate< int, void >, and Wt::Form::WFormDelegate< bool, void >.

◆ updateViewValue() [2/2]

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()

Generated on Thu Dec 23 2021 for the C++ Web Toolkit (Wt) by doxygen 1.8.13