<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>Wt: Wt::WTemplateFormView Class Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css" /> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="search/search.js"></script> <script type="text/javascript"> $(document).ready(function() { searchBox.OnSelectItem(0); }); </script> </head> <body> <div id="top"><!-- do not remove this div! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">Wt  <span id="projectnumber">3.2.3</span> </div> </td> </tr> </tbody> </table> </div> <!-- Generated by Doxygen 1.7.5.1 --> <script type="text/javascript"> var searchBox = new SearchBox("searchBox", "search",false,'Search'); </script> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li class="current"><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li> <div id="MSearchBox" class="MSearchBoxInactive"> <span class="left"> <img id="MSearchSelect" src="search/mag_sel.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/> <input type="text" id="MSearchField" value="Search" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/> </span><span class="right"> <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> </span> </div> </li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="inherits.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Class Members</span></a></li> </ul> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="namespaceWt.html">Wt</a> </li> <li class="navelem"><a class="el" href="classWt_1_1WTemplateFormView.html">WTemplateFormView</a> </li> </ul> </div> </div> <div class="header"> <div class="summary"> <a href="#pub-methods">Public Member Functions</a> | <a href="#pro-methods">Protected Member Functions</a> </div> <div class="headertitle"> <div class="title">Wt::WTemplateFormView Class Reference</div> </div> </div> <div class="contents"> <!-- doxytag: class="Wt::WTemplateFormView" --><!-- doxytag: inherits="Wt::WTemplate" --> <p>A template-based View class form form models. <a href="classWt_1_1WTemplateFormView.html#details">More...</a></p> <p><code>#include <Wt/WTemplateFormView></code></p> <div class="dynheader"> Inheritance diagram for Wt::WTemplateFormView:</div> <div class="dyncontent"> <div class="center"><img src="classWt_1_1WTemplateFormView__inherit__graph.png" border="0" usemap="#Wt_1_1WTemplateFormView_inherit__map" alt="Inheritance graph"/></div> <map name="Wt_1_1WTemplateFormView_inherit__map" id="Wt_1_1WTemplateFormView_inherit__map"> <area shape="rect" href="classWt_1_1Auth_1_1AuthWidget.html" title="An authentication widget." alt="" coords="5,453,155,480"/><area shape="rect" href="classWt_1_1Auth_1_1RegistrationWidget.html" title="A registration widget." alt="" coords="179,453,371,480"/><area shape="rect" href="classWt_1_1Auth_1_1UpdatePasswordWidget.html" title="A widget which allows a user to choose a new password." alt="" coords="395,453,613,480"/><area shape="rect" href="classWt_1_1WTemplate.html" title="A widget that renders an XHTML template." alt="" coords="219,304,331,331"/><area shape="rect" href="classWt_1_1WInteractWidget.html" title="An abstract widget that can receive user-interface interaction." alt="" coords="203,229,347,256"/><area shape="rect" href="classWt_1_1WWebWidget.html" title="A base class for widgets with an HTML counterpart." alt="" coords="211,155,339,181"/><area shape="rect" href="classWt_1_1WWidget.html" title="The abstract base class for a user-interface component." alt="" coords="225,80,324,107"/><area shape="rect" href="classWt_1_1WObject.html" title="A base class for objects that participate in the signal/slot system." alt="" coords="227,5,323,32"/></map> <center><span class="legend">[<a href="graph_legend.html">legend</a>]</span></center></div> <p><a href="classWt_1_1WTemplateFormView-members.html">List of all members.</a></p> <table class="memberdecls"> <tr><td colspan="2"><h2><a name="pub-methods"></a> Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a335b145e0ff015435bf118aa380083d6"></a><!-- doxytag: member="Wt::WTemplateFormView::WTemplateFormView" ref="a335b145e0ff015435bf118aa380083d6" args="(WContainerWidget *parent=0)" -->  </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTemplateFormView.html#a335b145e0ff015435bf118aa380083d6">WTemplateFormView</a> (<a class="el" href="classWt_1_1WContainerWidget.html">WContainerWidget</a> *parent=0)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Constructor. <br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a2b0885a8f8b28dd84b243fc160cd3224"></a><!-- doxytag: member="Wt::WTemplateFormView::WTemplateFormView" ref="a2b0885a8f8b28dd84b243fc160cd3224" args="(const WString &text, WContainerWidget *parent=0)" -->  </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTemplateFormView.html#a2b0885a8f8b28dd84b243fc160cd3224">WTemplateFormView</a> (const <a class="el" href="classWt_1_1WString.html">WString</a> &text, <a class="el" href="classWt_1_1WContainerWidget.html">WContainerWidget</a> *parent=0)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Constructor. <br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTemplateFormView.html#abc0709f1ef21e4ed4c182a103d1a1885">updateViewField</a> (<a class="el" href="classWt_1_1WFormModel.html">WFormModel</a> *model, <a class="el" href="classWt_1_1WFormModel.html#a33c90b8c637bc83bbc57717175a5aa52">WFormModel::Field</a> field)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Creates or updates a field in the View. <a href="#abc0709f1ef21e4ed4c182a103d1a1885"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTemplateFormView.html#a4cfe1b5169a25651e33ebed6ee820b1b">updateModelField</a> (<a class="el" href="classWt_1_1WFormModel.html">WFormModel</a> *model, <a class="el" href="classWt_1_1WFormModel.html#a33c90b8c637bc83bbc57717175a5aa52">WFormModel::Field</a> field)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Updates a field value in the Model. <a href="#a4cfe1b5169a25651e33ebed6ee820b1b"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTemplateFormView.html#a07d05005f74f317938b7f8546f1d377a">updateView</a> (<a class="el" href="classWt_1_1WFormModel.html">WFormModel</a> *model)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Updates the View. <a href="#a07d05005f74f317938b7f8546f1d377a"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTemplateFormView.html#a520a5ac27adee0e97d01ae6e064186e4">updateModel</a> (<a class="el" href="classWt_1_1WFormModel.html">WFormModel</a> *model)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Updates the Model. <a href="#a520a5ac27adee0e97d01ae6e064186e4"></a><br/></td></tr> <tr><td colspan="2"><h2><a name="pro-methods"></a> Protected Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="classWt_1_1WFormWidget.html">WFormWidget</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTemplateFormView.html#a561f9d5afe770bf3296ab41177edb652">createFormWidget</a> (<a class="el" href="classWt_1_1WFormModel.html#a33c90b8c637bc83bbc57717175a5aa52">WFormModel::Field</a> field)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Creates a form widget. <a href="#a561f9d5afe770bf3296ab41177edb652"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTemplateFormView.html#a45003d04398bef04c2e6cea978f10574">indicateValidation</a> (<a class="el" href="classWt_1_1WFormModel.html#a33c90b8c637bc83bbc57717175a5aa52">WFormModel::Field</a> field, bool validated, <a class="el" href="classWt_1_1WText.html">WText</a> *info, <a class="el" href="classWt_1_1WFormWidget.html">WFormWidget</a> *edit, const <a class="el" href="classWt_1_1WValidator_1_1Result.html">WValidator::Result</a> &validation)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Indicates the validation result. <a href="#a45003d04398bef04c2e6cea978f10574"></a><br/></td></tr> </table> <hr/><a name="details" id="details"></a><h2>Detailed Description</h2> <div class="textblock"><p>A template-based View class form form models. </p> <p>This implements a View to be used in conjunction with <a class="el" href="classWt_1_1WFormModel.html" title="A basic model class for forms.">WFormModel</a> models to implement forms.</p> <p>For a model field, it uses a number of conventional variable names to represent the label, editor, and validation messages in the template:</p> <ul> <li>'field': the form widget which contains the value</li> <li>'field-label': the label</li> <li>'field-info': a text that contains the validation message</li> <li>'if:field': condition for the visibility of the field</li> </ul> <p>For a field with name 'field', a typical template uses blocks of the following-format:</p> <div class="fragment"><pre class="fragment"> * ${<if:field>} * <label for="${id:field}">${field-label}</label> * ${field} ${field-info} * ${</if:field>} * </pre></div><p>The View may render fields of more than one model, and does not necessarily need to render all information of each model: you can call the <a class="el" href="classWt_1_1WTemplateFormView.html#abc0709f1ef21e4ed4c182a103d1a1885" title="Creates or updates a field in the View.">updateViewField()</a> and <a class="el" href="classWt_1_1WTemplateFormView.html#a4cfe1b5169a25651e33ebed6ee820b1b" title="Updates a field value in the Model.">updateModelField()</a> for individual model fields.</p> <p>The <a class="el" href="classWt_1_1WTemplateFormView.html#a07d05005f74f317938b7f8546f1d377a" title="Updates the View.">updateView()</a> method updates the view based on a model (e.g. to propagate changed values or validation), while the <a class="el" href="classWt_1_1WTemplateFormView.html#a520a5ac27adee0e97d01ae6e064186e4" title="Updates the Model.">updateModel()</a> method updates a model with values entered in the View.</p> <p>The view is passive: it will not perform any updates by itself of either the View or Model. You will typically bind a method to the Ok button and do: </p> <div class="fragment"><pre class="fragment"> <span class="keywordtype">void</span> MyView::okClicked() { <a class="code" href="classWt_1_1WTemplateFormView.html#a520a5ac27adee0e97d01ae6e064186e4" title="Updates the Model.">updateModel</a>(model_); <span class="keywordflow">if</span> (model_->validate()) { ... } <span class="keywordflow">else</span> { <a class="code" href="classWt_1_1WTemplateFormView.html#a07d05005f74f317938b7f8546f1d377a" title="Updates the View.">updateView</a>(model_); } } </pre></div> </div><hr/><h2>Member Function Documentation</h2> <a class="anchor" id="a561f9d5afe770bf3296ab41177edb652"></a><!-- doxytag: member="Wt::WTemplateFormView::createFormWidget" ref="a561f9d5afe770bf3296ab41177edb652" args="(WFormModel::Field field)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classWt_1_1WFormWidget.html">WFormWidget</a> * Wt::WTemplateFormView::createFormWidget </td> <td>(</td> <td class="paramtype"><a class="el" href="classWt_1_1WFormModel.html#a33c90b8c637bc83bbc57717175a5aa52">WFormModel::Field</a> </td> <td class="paramname"><em>field</em></td><td>)</td> <td><code> [protected, virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Creates a form widget. </p> <p>This method is called by <a class="el" href="classWt_1_1WTemplateFormView.html#abc0709f1ef21e4ed4c182a103d1a1885" title="Creates or updates a field in the View.">updateViewField()</a> when it needs to create a form widget for a field. You either need to make sure these widgets have been created and bound before calling <a class="el" href="classWt_1_1WTemplateFormView.html#a07d05005f74f317938b7f8546f1d377a" title="Updates the View.">updateView()</a>, or you need to specialize this method to do it on-demand. </p> <p>Reimplemented in <a class="el" href="classWt_1_1Auth_1_1AuthWidget.html#a6ff8949bfa82025e0e5e2b093fb839fc">Wt::Auth::AuthWidget</a>, <a class="el" href="classWt_1_1Auth_1_1RegistrationWidget.html#a19bfa5f81dfc00843053852743238ba5">Wt::Auth::RegistrationWidget</a>, and <a class="el" href="classWt_1_1Auth_1_1UpdatePasswordWidget.html#a0353ffa42916f8d7adfe470085617f26">Wt::Auth::UpdatePasswordWidget</a>.</p> </div> </div> <a class="anchor" id="a45003d04398bef04c2e6cea978f10574"></a><!-- doxytag: member="Wt::WTemplateFormView::indicateValidation" ref="a45003d04398bef04c2e6cea978f10574" args="(WFormModel::Field field, bool validated, WText *info, WFormWidget *edit, const WValidator::Result &validation)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void Wt::WTemplateFormView::indicateValidation </td> <td>(</td> <td class="paramtype"><a class="el" href="classWt_1_1WFormModel.html#a33c90b8c637bc83bbc57717175a5aa52">WFormModel::Field</a> </td> <td class="paramname"><em>field</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">bool </td> <td class="paramname"><em>validated</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="classWt_1_1WText.html">WText</a> * </td> <td class="paramname"><em>info</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="classWt_1_1WFormWidget.html">WFormWidget</a> * </td> <td class="paramname"><em>edit</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="classWt_1_1WValidator_1_1Result.html">WValidator::Result</a> & </td> <td class="paramname"><em>validation</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td><code> [protected, virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Indicates the validation result. </p> <p>The default implementation will set "Wt-valid" or "Wt-invalid" on the form widget, and "Wt-error" on the info text. </p> </div> </div> <a class="anchor" id="a520a5ac27adee0e97d01ae6e064186e4"></a><!-- doxytag: member="Wt::WTemplateFormView::updateModel" ref="a520a5ac27adee0e97d01ae6e064186e4" args="(WFormModel *model)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void Wt::WTemplateFormView::updateModel </td> <td>(</td> <td class="paramtype"><a class="el" href="classWt_1_1WFormModel.html">WFormModel</a> * </td> <td class="paramname"><em>model</em></td><td>)</td> <td><code> [virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Updates the Model. </p> <p>This creates or updates all field values in the model.</p> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classWt_1_1WTemplateFormView.html#a4cfe1b5169a25651e33ebed6ee820b1b" title="Updates a field value in the Model.">updateModelField()</a>, <a class="el" href="classWt_1_1WFormModel.html#aa0291a84a835f1398b39fe8d1e8bd08c" title="Returns the fields.">WFormModel::fields()</a> </dd></dl> </div> </div> <a class="anchor" id="a4cfe1b5169a25651e33ebed6ee820b1b"></a><!-- doxytag: member="Wt::WTemplateFormView::updateModelField" ref="a4cfe1b5169a25651e33ebed6ee820b1b" args="(WFormModel *model, WFormModel::Field field)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void Wt::WTemplateFormView::updateModelField </td> <td>(</td> <td class="paramtype"><a class="el" href="classWt_1_1WFormModel.html">WFormModel</a> * </td> <td class="paramname"><em>model</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="classWt_1_1WFormModel.html#a33c90b8c637bc83bbc57717175a5aa52">WFormModel::Field</a> </td> <td class="paramname"><em>field</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td><code> [virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Updates a field value in the Model. </p> <p>This propagates data entered in the form widget to the model with <a class="el" href="classWt_1_1WFormModel.html#a6b407653aa026154d158b21b0900ed12" title="Sets the field value.">WFormModel::setValue()</a> </p> </div> </div> <a class="anchor" id="a07d05005f74f317938b7f8546f1d377a"></a><!-- doxytag: member="Wt::WTemplateFormView::updateView" ref="a07d05005f74f317938b7f8546f1d377a" args="(WFormModel *model)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void Wt::WTemplateFormView::updateView </td> <td>(</td> <td class="paramtype"><a class="el" href="classWt_1_1WFormModel.html">WFormModel</a> * </td> <td class="paramname"><em>model</em></td><td>)</td> <td><code> [virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Updates the View. </p> <p>This creates or updates all fields in the view.</p> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classWt_1_1WTemplateFormView.html#abc0709f1ef21e4ed4c182a103d1a1885" title="Creates or updates a field in the View.">updateViewField()</a>, <a class="el" href="classWt_1_1WFormModel.html#aa0291a84a835f1398b39fe8d1e8bd08c" title="Returns the fields.">WFormModel::fields()</a> </dd></dl> </div> </div> <a class="anchor" id="abc0709f1ef21e4ed4c182a103d1a1885"></a><!-- doxytag: member="Wt::WTemplateFormView::updateViewField" ref="abc0709f1ef21e4ed4c182a103d1a1885" args="(WFormModel *model, WFormModel::Field field)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void Wt::WTemplateFormView::updateViewField </td> <td>(</td> <td class="paramtype"><a class="el" href="classWt_1_1WFormModel.html">WFormModel</a> * </td> <td class="paramname"><em>model</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="classWt_1_1WFormModel.html#a33c90b8c637bc83bbc57717175a5aa52">WFormModel::Field</a> </td> <td class="paramname"><em>field</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td><code> [virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Creates or updates a field in the View. </p> <p>This will update or create and bind widgets in the template to represent the field. To create the form widget that implements the editing, it calls <a class="el" href="classWt_1_1WTemplateFormView.html#a561f9d5afe770bf3296ab41177edb652" title="Creates a form widget.">createFormWidget()</a>. </p> </div> </div> </div> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Enumerator</a></div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <hr size="1"><address style="text-align: right; margin: 3px"><small> Generated on Thu Nov 1 2012 for <a href="http://www.webtoolkit.eu/wt">the C++ Web Toolkit (Wt)</a> by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" border="0" style="vertical-align: middle; display: inline-block; height: 2em"></a> 1.7.5.1</small></address> </body> </html>