Public Member Functions | Protected Member Functions | List of all members
cppcms::widgets::base_widget Class Referenceabstract

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

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)
bool readonly ()
void readonly (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 &)
- Public Member Functions inherited from cppcms::base_form
virtual void load (http::context &context)=0

Protected Member Functions

void auto_generate (form_context *context=0)

Additional Inherited Members

- Public Types inherited from cppcms::form_flags
enum  html_type { as_html = 0, as_xhtml = 1 }
enum  html_list_type {
  as_p = 0, as_table = 1, as_ul = 2, as_dl = 3,
  as_space = 4
enum  widget_part_type { first_part = 0, second_part = 1 }

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

cppcms::widgets::base_widget::base_widget ( )

Default constructor.

Member Function Documentation

std::string cppcms::widgets::base_widget::attributes_string ( )

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

void cppcms::widgets::base_widget::attributes_string ( std::string  v)

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)

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

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

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 >.

bool cppcms::widgets::base_widget::disabled ( )

Get the HTML disabled attribute.

void cppcms::widgets::base_widget::disabled ( bool  )

Set/Unset the HTML disabled attribute.

locale::message cppcms::widgets::base_widget::error_message ( )

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

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

Set the error message that is displayed for invalid widgets.

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

void cppcms::widgets::base_widget::error_message ( locale::message const &  )

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

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

bool cppcms::widgets::base_widget::has_error_message ( )

Check if an error message is set.

bool cppcms::widgets::base_widget::has_help ( )

Check if a help message is set.

bool cppcms::widgets::base_widget::has_message ( )

Check if a message is set.

locale::message cppcms::widgets::base_widget::help ( )

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.

void cppcms::widgets::base_widget::help ( locale::message const &  msg)

Set a translatable help message that describes this widget.

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

Get the HTML id attribute.

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

Set the HTML id attribute of the widget.

locale::message cppcms::widgets::base_widget::message ( )

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.

void cppcms::widgets::base_widget::message ( locale::message const &  )

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.

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

Get the HTML name attribute.

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)

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.

virtual form* cppcms::widgets::base_widget::parent ( )

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.

void cppcms::widgets::base_widget::pre_load ( http::context )

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

bool cppcms::widgets::base_widget::readonly ( )

Get the HTML readonly attribute.

New in CppCMS 1.2

void cppcms::widgets::base_widget::readonly ( bool  )

Set/Unset the HTML readonly attribute.

New in CppCMS 1.2

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

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)

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.

bool cppcms::widgets::base_widget::set ( )

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

void cppcms::widgets::base_widget::set ( bool  )

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".

bool cppcms::widgets::base_widget::valid ( )

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

void cppcms::widgets::base_widget::valid ( bool  )

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

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