CppCMS
Public Member Functions | Protected Member Functions
cppcms::widgets::base_widget Class Reference

this class is the base class of all renderable widgets which can be used with CppCMS form system. More...

#include <cppcms/form.h>

Inheritance diagram for cppcms::widgets::base_widget:
cppcms::base_form booster::noncopyable cppcms::form_flags cppcms::widgets::base_html_input cppcms::widgets::base_text cppcms::widgets::select_base cppcms::widgets::select_multiple cppcms::widgets::checkbox cppcms::widgets::file cppcms::widgets::numeric< T > cppcms::widgets::submit cppcms::widgets::text cppcms::widgets::text cppcms::widgets::textarea cppcms::widgets::radio cppcms::widgets::select

List of all members.

Public Member Functions

 base_widget ()
bool set ()
bool valid ()
std::string id ()
std::string name ()
locale::message message ()
bool has_message ()
locale::message error_message ()
bool has_error_message ()
locale::message help ()
bool has_help ()
bool disabled ()
void disabled (bool)
std::string attributes_string ()
void set (bool)
void valid (bool)
void id (std::string)
void name (std::string)
void message (std::string)
void message (locale::message const &)
void error_message (std::string)
void error_message (locale::message const &)
void help (std::string)
void help (locale::message const &msg)
void attributes_string (std::string v)
virtual void render (form_context &context)
virtual void render_input (form_context &context)=0
virtual void clear ()
virtual bool validate ()
virtual void render_attributes (form_context &context)
virtual void parent (base_form *subform)
virtual formparent ()
void pre_load (http::context &)

Protected Member Functions

void auto_generate (form_context *context=0)

Detailed Description

this class is the base class of all renderable widgets which can be used with CppCMS form system.

All cppcms widgets are derived from this class. Users who want to create their own custom widgets must derive them from this class.


Constructor & Destructor Documentation

Default constructor.


Member Function Documentation

Get the general user defined attribute string that can be added to the widget.

Set general HTML attributes that are not directly supported For example:

  my_widget.attributes_string("style='direction:rtl' onclick='return foo()'");

This string is inserted as-is just after render_input_start.

void cppcms::widgets::base_widget::auto_generate ( form_context context = 0) [protected]

This function should be called by overloadeding the load/render methods before the loading/rendering starts.

virtual void cppcms::widgets::base_widget::clear ( ) [virtual]

Clear the form. It also calls set(false).

Implements cppcms::base_form.

Reimplemented in cppcms::widgets::select_base, cppcms::widgets::select_multiple, and cppcms::widgets::numeric< T >.

Get the HTML disabled attribute.

Set/Unset the HTML disabled attribute.

Get the error message that would be displayed near the widget if the widget validation failed.

Set the error message that is displayed for invalid widgets.

If it is not set, a simple "*" is shown instead.

Set the translatable error message that is displayed for invalid widgets.

If it is not set, a simple "*" is shown instead.

Check if an error message is set.

Check if a help message is set.

Check if a message is set.

Get the eventual long description of the wigget.

void cppcms::widgets::base_widget::help ( std::string  )

Set a longer help message that describes this widget.

Set a translatable help message that describes this widget.

Get the HTML id attribute.

void cppcms::widgets::base_widget::id ( std::string  )

Set the HTML id attribute of the widget.

Get the short message that would be displayed near the widget.

void cppcms::widgets::base_widget::message ( std::string  )

Set a short description for the widget. Generally, it is a good idea to define this value.

The short message can also be set using the base_widget constructor.

Set a short translatable description for the widget. Generally, it is a good idea to define this value.

The short message can also be set using the base_widget constructor.

Get the HTML name attribute.

Referenced by cppcms::widgets::numeric< T >::load().

void cppcms::widgets::base_widget::name ( std::string  )

Set the HTML name attribute of the widget. Note: if this attribute is not set, the widget will not be able to be loaded from the POST/GET data.

virtual void cppcms::widgets::base_widget::parent ( base_form subform) [virtual]

Set the parent of this widget. It is used internally; you should not use it. It is called when the form is added or attached to another form.

Implements cppcms::base_form.

Get the parent of this form. If this is the topmost form, NULL is returned. It is assumed that the parent is always a form.

Implements cppcms::base_form.

This function should be called before actual loading of widgets, it performs cross widgets validation and causes automatic generation of undefined names

Referenced by cppcms::widgets::numeric< T >::load().

virtual void cppcms::widgets::base_widget::render ( form_context context) [virtual]

Render the full widget together with error messages and decorations as paragraphs or table elements to the output set in cppcms::form_context::out().

Implements cppcms::base_form.

Reimplemented in cppcms::widgets::hidden.

virtual void cppcms::widgets::base_widget::render_attributes ( form_context context) [virtual]

Render standard common attributes like id, name, disabled, etc.

Reimplemented in cppcms::widgets::text.

virtual void cppcms::widgets::base_widget::render_input ( form_context context) [pure virtual]

This is a virtual member function that should be implemented by each widget. It executes the actual rendering of the HTML form.

Implemented in cppcms::widgets::radio, cppcms::widgets::select, cppcms::widgets::select_base, cppcms::widgets::select_multiple, cppcms::widgets::textarea, and cppcms::widgets::base_html_input.

Check if a value has been assigned to the widget. It is usually true when the user has assigned a value to the widget or when the widget is loaded.

If there is a reasonable default value for the widget then set() should be true. For widgets like file or numeric where explicit parsing is required, the set() value would indicate that user provided some value (i.e. uploaded a file or entered a number).

Set the existence of content for the widget. By default the widget is not set. By convention, trying to fetch a value from a widget that is "unset" will throw an exception. Call set(true) to change the state to "set" and call set(false) to change it to "unset".

After having executed the validation process, each widget can be tested for validity.

Referenced by cppcms::widgets::numeric< T >::load(), and cppcms::widgets::numeric< T >::validate().

Set th validity state of the widget. By default the widget is valid. If it fails to pass the validation, its validity state is changed by calling this function.

Note: a widget may be "unset" and still be valid. Conversely, it may be set but be not-valid.

virtual bool cppcms::widgets::base_widget::validate ( ) [virtual]

The documentation for this class was generated from the following file: