Wtx ~ Wt Extension Library
WtxLib
|
Public Types | |
enum | State { Unknown = -1, Clean = 0, Dirty = 1, Collision = 2 } |
Public Member Functions | |
Wt::Dbo::ptr< C > | load (int id, Wt::Dbo::Session *s) |
Return a loaded item. More... | |
FormModel (int id, Wt::Dbo::Session *s) | |
ctor More... | |
FormModel (const Wt::Dbo::ptr< C > &itm) | |
ctor More... | |
virtual std::string | tableName () const |
Table Name. | |
virtual int | itemId () const |
Item ID. | |
const Wt::Dbo::ptr< C > & | item () const |
Referenced Item. More... | |
Wt::Dbo::ptr< C > & | item () |
Referenced Item. More... | |
Wt::Dbo::Session * | session () const |
Session Reference. More... | |
virtual bool | remove () |
Delete Item from DB. More... | |
virtual int | read () |
Read Item. More... | |
virtual void | refresh () |
Refresh Item. More... | |
virtual std::unique_ptr< Wt::WWidget > | createEditWidget (Wt::WFormModel::Field f) const |
virtual void | staleRefresh () |
virtual bool | isStale () const |
Check Memory against Disk. More... | |
virtual int | diskVersion () const |
Report disk version. More... | |
virtual int | itemVersion () const |
const Field | field (const std::string &fieldName) const |
Return Field Element. More... | |
virtual const Wt::cpp17::any & | value (const std::string &fieldName) const |
virtual const Wt::cpp17::any & | value (const Wtx::Dbo::FieldDefBase &fieldDef) const |
virtual const Wt::cpp17::any & | value (const Wt::WFormModel::Field field) const |
virtual int | accept () |
virtual void | reset () |
virtual bool | validate () |
virtual bool | isVisible (Wt::WFormModel::Field field) const |
virtual bool | isReadOnly (Wt::WFormModel::Field field) const |
virtual Wt::WString | label (Wt::WFormModel::Field field) const |
Get Field Label. More... | |
virtual void | setValue (Wt::WFormModel::Field field, const Wt::cpp17::any &value) |
virtual Wt::WString | valueText (Wt::WFormModel::Field field) const |
virtual void | setValidator (Wt::WFormModel::Field field, const std::shared_ptr< Wt::WValidator > &validator) |
virtual std::shared_ptr< Wt::WValidator > | validator (Wt::WFormModel::Field field) const |
virtual bool | validateField (Wt::WFormModel::Field field) |
virtual void | setValidated (Wt::WFormModel::Field field, bool validated) |
virtual bool | isValidated (Wt::WFormModel::Field field) const |
virtual void | setValidation (Wt::WFormModel::Field field, const Wt::WValidator::Result &result) |
template<typename T > | |
void | act (Wt::Dbo::FieldRef< T > ref) |
template<typename T > | |
void | actPtr (const Wt::Dbo::PtrRef< T > &ref) |
template<typename T > | |
void | actWeakPtr (const Wt::Dbo::WeakPtrRef< T > &ref) |
template<typename T > | |
void | actCollection (const Wt::Dbo::CollectionRef< T > &ret) |
template<typename T > | |
void | act (Wt::Dbo::FieldRef< T > ref) |
template<typename T > | |
void | actPtr (const Wt::Dbo::PtrRef< T > &ref) |
template<typename T > | |
void | actWeakPtr (const Wt::Dbo::WeakPtrRef< T > &ref) |
template<typename T > | |
void | actCollection (const Wt::Dbo::CollectionRef< T > &ref) |
Public Member Functions inherited from Wtx::FormModel | |
FormModel (Wtx::Dbo::TableDef &td) | |
Wtx::Dbo::TableDef & | tableDef () const |
virtual std::unique_ptr< Wt::WWidget > | createWidget (Wtx::Dbo::Session &session) |
Protected Attributes | |
Wt::Dbo::ptr< C > | m_item |
Definition at line 61 of file FormModel.h.
enum Wtx::Dbo::FormModel::State |
Definition at line 66 of file FormModel.h.
FormModel::FormModel | ( | int | id, |
Wt::Dbo::Session * | s | ||
) |
FormModel::FormModel | ( | const Wt::Dbo::ptr< C > & | itm | ) |
|
virtual |
Report disk version.
This function will check the version of the item on the back-end storage and return the version number of it there. This is used to check if the item is stale before any attempt is made to write the item back to disk ~ a task that will surely fail.
Definition at line 211 of file FormModel.h.
const Wt::WFormModel::Field FormModel::field | ( | const std::string & | fieldName | ) | const |
Return Field Element.
This returns the field element based on a string-representation of that same field name.
Definition at line 238 of file FormModel.h.
|
virtual |
Check Memory against Disk.
This will return true if the item in back-end storage is out of sync with the memory item. This is based on the assumption that at least the item we are referencing actually has an ID assigned. For those items that have no ID assigned yet, this function simply returns 'false' that the item we are referencing is not stale ~ it has no storage yet, how can it be stale?
Definition at line 199 of file FormModel.h.
const Wt::Dbo::ptr< C > & Wtx::Dbo::FormModel< C >::item | ( | ) | const |
Referenced Item.
This returns a const reference to item.
Definition at line 102 of file FormModel.h.
Wt::Dbo::ptr< C > & FormModel::item | ( | ) |
Referenced Item.
This returns a non-const reference to item.
Definition at line 111 of file FormModel.h.
|
virtual |
This will return the proper 'label' for a form field.
This will try first to get a label from the field-definition.
If there is no value in the field-def object, then this will turn to the base-class to see if there is a field-name in the transaltion table somewhere. According to the Wt docs, the system by default will perform a WString::tr(fieldName) and return that by default, so if there is no transaltion for this field name, then the return value is going to have '??fieldName??' (double-question-marks) surrounding the field name.
if the field-name could not be transalted properly, then this will just default to the actual field name itself, so that it doesn't look 'goofy' on the screens like '??keyField??' and so on...
Reimplemented from Wtx::FormModel.
Definition at line 378 of file FormModel.h.
Wt::Dbo::ptr< C > FormModel::load | ( | int | id, |
Wt::Dbo::Session * | s | ||
) |
Return a loaded item.
This is used in a constructor to return an item pointer based on the ID number provided. In order for this task to be completed, a Wt::Transaction must exist. So it is all done here, so that the result can be used in a constructor.
Definition at line 52 of file FormModel.h.
|
virtual |
Read Item.
This will read the item in from the back-end DB.
Definition at line 146 of file FormModel.h.
|
virtual |
Refresh Item.
This will refresh the item from the back-end DB.
Definition at line 159 of file FormModel.h.
|
virtual |
Delete Item from DB.
This will remove the item from the back-end DB and purge it from memory as well.
Definition at line 129 of file FormModel.h.
Wt::Dbo::Session * FormModel::session | ( | ) | const |
Session Reference.
This returns a pointer to the current session.
Definition at line 120 of file FormModel.h.