Wt::WViewWidget Class Reference

An abstract base class for a MVC view that is rendered using a widget. More...

#include <Wt/WViewWidget>

Inheritance diagram for Wt::WViewWidget:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 WViewWidget (WContainerWidget *parent=0)
 Create a new view widget.
void update ()
 Update the view.

Protected Member Functions

virtual WWidgetrenderView ()=0
 Create a widget that renders the View.
virtual void load ()
 Load content just before the widget's content is rendered.
virtual void refresh ()
 Refresh the widget.


Detailed Description

An abstract base class for a MVC view that is rendered using a widget.

In principle, Wt widgets are self-contained and implement the Model, View and Controller of the so-called Model-View-Controller (MVC) design pattern. This allows the developer to keep Model and View together, or, seperate Model and View in any way that he likes.

This widget facilitates separation of the View from the Model and Controller in a particular way. The use of this widget provides two benefits. The classic MVC benefit is a decoupling between view and model, which would allow easier maintainance of code (although that is debatable for a highly interactive application). In addition, this widget enforces the View to be stateless, as it is only created transiently on the server. Therefore the View does not require session resources. This may increase scalability for Internet-deployments.

The View is rendered as a widget, but this widget is created only temporarily on the server side, each time that rendering is needed. This rendered view must simply reflect the state of the model.

Currently, the View cannot enclose FormWidget objects which would allow direct manipulation of the model (but we are working to remove this limitation in the future, and let the Model/Controller handle editing changes) and the View may only be updated by a complete rerendering of the entire view.

The View widget may contain event handling code, but only in one of the following ways:

Thus, currently, event handling code related to the View cannot be implemented at server-side (but we are thinking about a solution for this as well...).

The renderView() method must be implemented to create widgets that reflect the current state of the model. Whenever the model is changed, a call to update() will rerender the View.


Member Function Documentation

void Wt::WViewWidget::update (  ) 

Update the view.

Typically, the model will want to update the view when the model has changed.

This will trigger a call to renderView() to ask for a new rendering of the view.

virtual WWidget* Wt::WViewWidget::renderView (  )  [protected, pure virtual]

Create a widget that renders the View.

This method must be reimplemented to return a widget that renders the view. The returned widget will be deleted by WViewWidget.

Implemented in Wt::WStaticModelView< Renderer >.

void Wt::WViewWidget::load (  )  [protected, virtual]

Load content just before the widget's content is rendered.

As soon as a widget is inserted into the widget hierarchy, it is rendered. Visible widgets are rendered immediately, and invisible widgets in the back-ground. This method is called when the widget is directly or indirectly inserted into the widget tree.

The default implementation simply propagates the load signal to its children. You may want to override this method to load resource-intensive content only when the widget is loaded into the browser.

Reimplemented from Wt::WWebWidget.

void Wt::WViewWidget::refresh (  )  [protected, virtual]

Refresh the widget.

The refresh method is invoked when the locale is changed using WApplication::setLocale() or when the user hit the refresh button.

The widget must actualize its contents in response.

Reimplemented from Wt::WWebWidget.


Generated on Mon Nov 3 15:01:04 2008 for Wt by doxygen 1.5.6