本文整理汇总了C++中DomElement::saveChild方法的典型用法代码示例。如果您正苦于以下问题:C++ DomElement::saveChild方法的具体用法?C++ DomElement::saveChild怎么用?C++ DomElement::saveChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DomElement
的用法示例。
在下文中一共展示了DomElement::saveChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateDom
void WTemplate::updateDom(DomElement& element, bool all)
{
if (changed_ || all) {
std::set<WWidget *> previouslyRendered;
std::vector<WWidget *> newlyRendered;
for (WidgetMap::const_iterator i = widgets_.begin(); i != widgets_.end();
++i) {
WWidget *w = i->second;
if (w->isRendered() && w->webWidget()->domCanBeSaved()) {
previouslyRendered.insert(w);
}
}
bool saveWidgets = element.mode() == DomElement::ModeUpdate;
previouslyRendered_ = saveWidgets ? &previouslyRendered : 0;
newlyRendered_ = &newlyRendered;
std::stringstream html;
renderTemplate(html);
previouslyRendered_ = 0;
newlyRendered_ = 0;
for (unsigned i = 0; i < newlyRendered.size(); ++i) {
WWidget *w = newlyRendered[i];
if (previouslyRendered.find(w) != previouslyRendered.end()) {
if (saveWidgets)
element.saveChild(w->id());
previouslyRendered.erase(w);
}
}
element.setProperty(Wt::PropertyInnerHTML, html.str());
changed_ = false;
for (std::set<WWidget *>::const_iterator i = previouslyRendered.begin();
i != previouslyRendered.end(); ++i) {
WWidget *w = *i;
w->webWidget()->setRendered(false);
}
}
WInteractWidget::updateDom(element, all);
}
示例2: updateDom
void WTemplate::updateDom(DomElement& element, bool all)
{
if (changed_ || all) {
std::set<WWidget *> previouslyRendered;
std::vector<WWidget *> newlyRendered;
for (WidgetMap::const_iterator i = widgets_.begin(); i != widgets_.end();
++i) {
WWidget *w = i->second;
if (w->isRendered() && w->webWidget()->domCanBeSaved()) {
previouslyRendered.insert(w);
}
}
bool saveWidgets = element.mode() == DomElement::ModeUpdate;
previouslyRendered_ = saveWidgets ? &previouslyRendered : 0;
newlyRendered_ = &newlyRendered;
std::stringstream html;
renderTemplate(html);
previouslyRendered_ = 0;
newlyRendered_ = 0;
for (unsigned i = 0; i < newlyRendered.size(); ++i) {
WWidget *w = newlyRendered[i];
if (previouslyRendered.find(w) != previouslyRendered.end()) {
if (saveWidgets)
element.saveChild(w->id());
previouslyRendered.erase(w);
}
}
if (encodeTemplateText_)
element.setProperty(Wt::PropertyInnerHTML, html.str());
else
element.setProperty(Wt::PropertyInnerHTML, encode(html.str()));
changed_ = false;
for (std::set<WWidget *>::const_iterator i = previouslyRendered.begin();
i != previouslyRendered.end(); ++i) {
WWidget *w = *i;
// it could be that the widget was removed/deleted in the mean time
// as a side-effect of rendering some of the widgets; thus we check
// that the widget is still a child
for (WidgetMap::const_iterator j = widgets_.begin();
j != widgets_.end(); ++j) {
if (j->second == w) {
w->webWidget()->setRendered(false);
break;
}
}
}
WApplication::instance()->session()->renderer()
.updateFormObjects(this, true);
}
WInteractWidget::updateDom(element, all);
}