diff --git a/WebWidgets/ExtJS/include/Poco/WebWidgets/ExtJS/PanelRenderer.h b/WebWidgets/ExtJS/include/Poco/WebWidgets/ExtJS/PanelRenderer.h index 433b67944..cad73322a 100644 --- a/WebWidgets/ExtJS/include/Poco/WebWidgets/ExtJS/PanelRenderer.h +++ b/WebWidgets/ExtJS/include/Poco/WebWidgets/ExtJS/PanelRenderer.h @@ -46,6 +46,7 @@ namespace Poco { namespace WebWidgets { + class Panel; namespace ExtJS { @@ -61,6 +62,11 @@ public: void renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr); /// Emits code for the page header to the given output stream. + + void renderHeadWithoutChildren(const Panel* pPanel, const RenderContext& context, std::ostream& ostr); + /// Emits code for the page header to the given output stream. + + void renderAsPanelChild(const Panel* pPanel, const RenderContext& context, std::ostream& ostr); void renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr); /// Emits code for the page body to the given output stream. diff --git a/WebWidgets/ExtJS/src/DynamicCodeLoaderRenderer.cpp b/WebWidgets/ExtJS/src/DynamicCodeLoaderRenderer.cpp index 63a541faa..9f0eee447 100644 --- a/WebWidgets/ExtJS/src/DynamicCodeLoaderRenderer.cpp +++ b/WebWidgets/ExtJS/src/DynamicCodeLoaderRenderer.cpp @@ -35,10 +35,12 @@ #include "Poco/WebWidgets/ExtJS/DynamicCodeLoaderRenderer.h" +#include "Poco/WebWidgets/ExtJS/PanelRenderer.h" #include "Poco/WebWidgets/ExtJS/Utility.h" #include "Poco/WebWidgets/VerticalLayout.h" #include "Poco/WebWidgets/DynamicCodeLoader.h" #include "Poco/WebWidgets/RequestHandler.h" +#include "Poco/WebWidgets/Panel.h" #include "Poco/NumberFormatter.h" #include @@ -64,6 +66,8 @@ void DynamicCodeLoaderRenderer::renderHead(const Renderable* pRenderable, const // - first a load method in the header which loads a js file // - second, the js file which must be set as code at the DynamicCodeLoader const DynamicCodeLoader* pLoader = static_cast(pRenderable); + View::Ptr pView = pLoader->view(); + Panel::Ptr pPanel = pView.cast(); poco_assert_dbg (pLoader != 0); str << "var " << pLoader->loaderFunctionName() << "Loaded = false;" << std::endl; str << "function " << pLoader->loaderFunctionName() << "(){" << std::endl; @@ -74,7 +78,10 @@ void DynamicCodeLoaderRenderer::renderHead(const Renderable* pRenderable, const str << RequestHandler::KEY_ID << "=" << pLoader->id() << "'," << std::endl; str << "success: function(response){" << std::endl; str << "loadScriptDynamically('script" << pLoader->id() << "', response);" << std::endl; - str << "var parent = Ext.getCmp('" << pLoader->parent()->id() << "');" << std::endl; + if (pPanel) + str << "var parent = Ext.getCmp('" << pPanel->id() << "');" << std::endl; + else + str << "var parent = Ext.getCmp('" << pLoader->parent()->id() << "');" << std::endl; str << "var child = " << pLoader->functionName() << "();" << std::endl; str << "parent.add(child);" << std::endl; if (!pLoader->getSuccessCall().empty()) @@ -93,16 +100,21 @@ void DynamicCodeLoaderRenderer::renderHead(const Renderable* pRenderable, const // bug: this optimization breaks logout/login stuff! std::ostringstream out; - View::Ptr pView = pLoader->view(); + out << "function " << pLoader->functionName() << "(){"; out << "return "; - pView->renderHead(context, out); + // only render the child when we have a panel + if (pPanel) + { + AutoPtr pRend = new PanelRenderer(); + pRend->renderAsPanelChild(pPanel, context, out); + } + else + pView->renderHead(context, out); out << ";"; // close return out << "}"; pL->setViewCode(out.str()); - - } diff --git a/WebWidgets/ExtJS/src/LayoutRenderer.cpp b/WebWidgets/ExtJS/src/LayoutRenderer.cpp index 16242c89f..0e0978197 100644 --- a/WebWidgets/ExtJS/src/LayoutRenderer.cpp +++ b/WebWidgets/ExtJS/src/LayoutRenderer.cpp @@ -85,6 +85,13 @@ void LayoutRenderer::renderLayoutHead(const Layout* pLayout, const RenderContext void LayoutRenderer::renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr) { + const Layout* pLayout = static_cast(pRenderable); + ContainerView::ConstIterator it = pLayout->begin(); + int cnt(0); + for (; it != pLayout->end(); ++it) + { + (*it)->renderBody(context, ostr); + } } diff --git a/WebWidgets/ExtJS/src/PageRenderer.cpp b/WebWidgets/ExtJS/src/PageRenderer.cpp index 94e760aa7..ba49517ae 100644 --- a/WebWidgets/ExtJS/src/PageRenderer.cpp +++ b/WebWidgets/ExtJS/src/PageRenderer.cpp @@ -36,7 +36,9 @@ #include "Poco/WebWidgets/ExtJS/PageRenderer.h" #include "Poco/WebWidgets/ExtJS/Utility.h" +#include "Poco/WebWidgets/ExtJS/PanelRenderer.h" #include "Poco/WebWidgets/Page.h" +#include "Poco/WebWidgets/Panel.h" #include "Poco/WebWidgets/RenderContext.h" #include "Poco/WebWidgets/LookAndFeel.h" #include "Poco/WebWidgets/WebApplication.h" @@ -120,6 +122,8 @@ void PageRenderer::renderHead(const Renderable* pRenderable, const RenderContext //start inline javascript block ostr << "