Re: [Cppcms-users] Multiple class of render()
Brought to you by:
artyom-beilis
From: Artyom B. <art...@ya...> - 2012-06-21 09:36:41
|
----- Original Message ----- > From: Christian Gmeiner <chr...@gm...> > To: cpp...@li... > Cc: > Sent: Wednesday, June 20, 2012 5:34 PM > Subject: [Cppcms-users] Multiple class of render() > > Hi all, > > I found an interesting jquery lib, which speeds up page switching a > lot. This seems to > solve my performance problems I have on my embedded device. > Have a loot at it: https://github.com/defunkt/jquery-pjax > > I have replaced all calls of render with ajax_render, which looks like: > > void Base::ajax_render(std::string template_name, cppcms::base_content > &content) > { > bool chromeless = false; > if (request().getenv("HTTP_X_PJAX") == "true") > { > chromeless = true; > } > > BOOSTER_DEBUG("ajax_render") << "chromeless: " > << chromeless; > > if (chromeless) > { > render(template_name, content); > } > else > { > static content::master m; > render("header", m); > render(template_name, content); > > // as a template for footer is an overkill, we do it here > response().out() << " </div>\n"; > response().out() << "</body>\n"; > response().out() << "</html>\n"; > } > } > > Is the usage of multiple render class the best solution? > It seems to me as classic application of multiple skins. For example create one skin (basic HTML header, footer) for "PAJAX" and other for normal HTML. That what I would do. But this approach is fine as well. Also small note > ___static___ content::master m; It seems to me bad idea... Multiple threads can access same object. So unless you make sure m does not change be careful. Artyom Beilis ------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ > thanks > -- > Christian Gmeiner, MSc > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |