mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-18 03:29:47 +02:00
fixed zseed problem
This commit is contained in:
@@ -46,6 +46,7 @@
|
|||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace WebWidgets {
|
namespace WebWidgets {
|
||||||
|
class Panel;
|
||||||
namespace ExtJS {
|
namespace ExtJS {
|
||||||
|
|
||||||
|
|
||||||
@@ -61,6 +62,11 @@ public:
|
|||||||
|
|
||||||
void renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr);
|
void renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr);
|
||||||
/// Emits code for the page header to the given output stream.
|
/// 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);
|
void renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr);
|
||||||
/// Emits code for the page body to the given output stream.
|
/// Emits code for the page body to the given output stream.
|
||||||
|
@@ -35,10 +35,12 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "Poco/WebWidgets/ExtJS/DynamicCodeLoaderRenderer.h"
|
#include "Poco/WebWidgets/ExtJS/DynamicCodeLoaderRenderer.h"
|
||||||
|
#include "Poco/WebWidgets/ExtJS/PanelRenderer.h"
|
||||||
#include "Poco/WebWidgets/ExtJS/Utility.h"
|
#include "Poco/WebWidgets/ExtJS/Utility.h"
|
||||||
#include "Poco/WebWidgets/VerticalLayout.h"
|
#include "Poco/WebWidgets/VerticalLayout.h"
|
||||||
#include "Poco/WebWidgets/DynamicCodeLoader.h"
|
#include "Poco/WebWidgets/DynamicCodeLoader.h"
|
||||||
#include "Poco/WebWidgets/RequestHandler.h"
|
#include "Poco/WebWidgets/RequestHandler.h"
|
||||||
|
#include "Poco/WebWidgets/Panel.h"
|
||||||
#include "Poco/NumberFormatter.h"
|
#include "Poco/NumberFormatter.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
@@ -64,6 +66,8 @@ void DynamicCodeLoaderRenderer::renderHead(const Renderable* pRenderable, const
|
|||||||
// - first a load method in the header which loads a js file
|
// - 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
|
// - second, the js file which must be set as code at the DynamicCodeLoader
|
||||||
const DynamicCodeLoader* pLoader = static_cast<const DynamicCodeLoader*>(pRenderable);
|
const DynamicCodeLoader* pLoader = static_cast<const DynamicCodeLoader*>(pRenderable);
|
||||||
|
View::Ptr pView = pLoader->view();
|
||||||
|
Panel::Ptr pPanel = pView.cast<Panel>();
|
||||||
poco_assert_dbg (pLoader != 0);
|
poco_assert_dbg (pLoader != 0);
|
||||||
str << "var " << pLoader->loaderFunctionName() << "Loaded = false;" << std::endl;
|
str << "var " << pLoader->loaderFunctionName() << "Loaded = false;" << std::endl;
|
||||||
str << "function " << pLoader->loaderFunctionName() << "(){" << 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 << RequestHandler::KEY_ID << "=" << pLoader->id() << "'," << std::endl;
|
||||||
str << "success: function(response){" << std::endl;
|
str << "success: function(response){" << std::endl;
|
||||||
str << "loadScriptDynamically('script" << pLoader->id() << "', 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 << "var child = " << pLoader->functionName() << "();" << std::endl;
|
||||||
str << "parent.add(child);" << std::endl;
|
str << "parent.add(child);" << std::endl;
|
||||||
if (!pLoader->getSuccessCall().empty())
|
if (!pLoader->getSuccessCall().empty())
|
||||||
@@ -93,16 +100,21 @@ void DynamicCodeLoaderRenderer::renderHead(const Renderable* pRenderable, const
|
|||||||
// bug: this optimization breaks logout/login stuff!
|
// bug: this optimization breaks logout/login stuff!
|
||||||
|
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
View::Ptr pView = pLoader->view();
|
|
||||||
out << "function " << pLoader->functionName() << "(){";
|
out << "function " << pLoader->functionName() << "(){";
|
||||||
out << "return ";
|
out << "return ";
|
||||||
pView->renderHead(context, out);
|
// only render the child when we have a panel
|
||||||
|
if (pPanel)
|
||||||
|
{
|
||||||
|
AutoPtr<PanelRenderer> pRend = new PanelRenderer();
|
||||||
|
pRend->renderAsPanelChild(pPanel, context, out);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
pView->renderHead(context, out);
|
||||||
out << ";"; // close return
|
out << ";"; // close return
|
||||||
out << "}";
|
out << "}";
|
||||||
|
|
||||||
pL->setViewCode(out.str());
|
pL->setViewCode(out.str());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -85,6 +85,13 @@ void LayoutRenderer::renderLayoutHead(const Layout* pLayout, const RenderContext
|
|||||||
|
|
||||||
void LayoutRenderer::renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
|
void LayoutRenderer::renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
|
||||||
{
|
{
|
||||||
|
const Layout* pLayout = static_cast<const Layout*>(pRenderable);
|
||||||
|
ContainerView::ConstIterator it = pLayout->begin();
|
||||||
|
int cnt(0);
|
||||||
|
for (; it != pLayout->end(); ++it)
|
||||||
|
{
|
||||||
|
(*it)->renderBody(context, ostr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -36,7 +36,9 @@
|
|||||||
|
|
||||||
#include "Poco/WebWidgets/ExtJS/PageRenderer.h"
|
#include "Poco/WebWidgets/ExtJS/PageRenderer.h"
|
||||||
#include "Poco/WebWidgets/ExtJS/Utility.h"
|
#include "Poco/WebWidgets/ExtJS/Utility.h"
|
||||||
|
#include "Poco/WebWidgets/ExtJS/PanelRenderer.h"
|
||||||
#include "Poco/WebWidgets/Page.h"
|
#include "Poco/WebWidgets/Page.h"
|
||||||
|
#include "Poco/WebWidgets/Panel.h"
|
||||||
#include "Poco/WebWidgets/RenderContext.h"
|
#include "Poco/WebWidgets/RenderContext.h"
|
||||||
#include "Poco/WebWidgets/LookAndFeel.h"
|
#include "Poco/WebWidgets/LookAndFeel.h"
|
||||||
#include "Poco/WebWidgets/WebApplication.h"
|
#include "Poco/WebWidgets/WebApplication.h"
|
||||||
@@ -120,6 +122,8 @@ void PageRenderer::renderHead(const Renderable* pRenderable, const RenderContext
|
|||||||
//start inline javascript block
|
//start inline javascript block
|
||||||
ostr << "<script type=\"text/javascript\">";
|
ostr << "<script type=\"text/javascript\">";
|
||||||
ostr << "var global={};"; //global var to store values!
|
ostr << "var global={};"; //global var to store values!
|
||||||
|
ostr << "var winGrp = new Ext.WindowGroup();";
|
||||||
|
ostr << "winGrp.zseed = 5000;";
|
||||||
const std::vector<std::string>& fcts = pPage->dynamicFunctions();
|
const std::vector<std::string>& fcts = pPage->dynamicFunctions();
|
||||||
std::vector<std::string>::const_iterator itF = fcts.begin();
|
std::vector<std::string>::const_iterator itF = fcts.begin();
|
||||||
for (; itF != fcts.end(); ++itF)
|
for (; itF != fcts.end(); ++itF)
|
||||||
@@ -188,10 +192,30 @@ void PageRenderer::renderHead(const Renderable* pRenderable, const RenderContext
|
|||||||
ostr << ",width:Ext.lib.Dom.getViewWidth()-20";
|
ostr << ",width:Ext.lib.Dom.getViewWidth()-20";
|
||||||
|
|
||||||
ostr << ",items:[";
|
ostr << ",items:[";
|
||||||
|
// write an empty hull for the dynamiccodeloadres: solves z-seed problem
|
||||||
|
std::set<DynamicCodeLoader::Ptr>::const_iterator itDCL = dcls.begin();
|
||||||
|
AutoPtr<PanelRenderer> pPanelRenderer(new PanelRenderer());
|
||||||
|
bool writeComma = false;
|
||||||
|
for (; itDCL != dcls.end(); ++itDCL)
|
||||||
|
{
|
||||||
|
View::Ptr pView = (*itDCL)->view();
|
||||||
|
AutoPtr<Panel> pPanel = pView.cast<Panel>();
|
||||||
|
if (pPanel)
|
||||||
|
{
|
||||||
|
if (writeComma)
|
||||||
|
{
|
||||||
|
ostr << ",";
|
||||||
|
}
|
||||||
|
pPanelRenderer->renderHeadWithoutChildren(pPanel, context, ostr);
|
||||||
|
writeComma = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
//process all children
|
//process all children
|
||||||
ContainerView::ConstIterator it = pPage->begin();
|
ContainerView::ConstIterator it = pPage->begin();
|
||||||
ContainerView::ConstIterator itEnd = pPage->end();
|
ContainerView::ConstIterator itEnd = pPage->end();
|
||||||
|
if (!dcls.empty() && it != itEnd)
|
||||||
|
ostr << ",";
|
||||||
|
|
||||||
for (; it != itEnd; ++it)
|
for (; it != itEnd; ++it)
|
||||||
{
|
{
|
||||||
if (it != pPage->begin())
|
if (it != pPage->begin())
|
||||||
@@ -226,9 +250,21 @@ void PageRenderer::renderBody(const Renderable* pRenderable, const RenderContext
|
|||||||
if (!pPage->empty())
|
if (!pPage->empty())
|
||||||
{
|
{
|
||||||
//process all children: ExtJS is a JavaScript library, we NEVER write to the body
|
//process all children: ExtJS is a JavaScript library, we NEVER write to the body
|
||||||
|
// except for Panel!
|
||||||
ostr << "<div id=\"p" << pPage->id() << "\" />";
|
ostr << "<div id=\"p" << pPage->id() << "\" />";
|
||||||
// also a tmp id for temporary storage!
|
// also a tmp id for temporary storage!
|
||||||
ostr << "<div id=\"" << Utility::getTmpID() << "\" />";
|
ostr << "<div id=\"" << Utility::getTmpID() << "\" />";
|
||||||
|
/*
|
||||||
|
ContainerView::ConstIterator it = pPage->begin();
|
||||||
|
ContainerView::ConstIterator itEnd = pPage->end();
|
||||||
|
for (; it != itEnd; ++it)
|
||||||
|
{
|
||||||
|
if (it != pPage->begin())
|
||||||
|
ostr << ",";
|
||||||
|
|
||||||
|
(*it)->renderBody(context, ostr);
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
ostr << "</body>";
|
ostr << "</body>";
|
||||||
ostr << "</html>";
|
ostr << "</html>";
|
||||||
|
@@ -61,8 +61,9 @@ void PanelRenderer::renderHead(const Renderable* pRenderable, const RenderContex
|
|||||||
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::Panel));
|
poco_assert_dbg (pRenderable->type() == typeid(Poco::WebWidgets::Panel));
|
||||||
const Panel* pPanel = static_cast<const Poco::WebWidgets::Panel*>(pRenderable);
|
const Panel* pPanel = static_cast<const Poco::WebWidgets::Panel*>(pRenderable);
|
||||||
ostr << "new Ext.Window({";
|
ostr << "new Ext.Window({";
|
||||||
|
|
||||||
Utility::writeRenderableProperties(pRenderable, ostr);
|
Utility::writeRenderableProperties(pRenderable, ostr);
|
||||||
|
ostr << ",manager: winGrp";
|
||||||
if (!pPanel->getName().empty() && pPanel->showHeader())
|
if (!pPanel->getName().empty() && pPanel->showHeader())
|
||||||
ostr << ",title:'" << pPanel->getTitle() << "'";
|
ostr << ",title:'" << pPanel->getTitle() << "'";
|
||||||
if (pPanel->getWidth() > 0)
|
if (pPanel->getWidth() > 0)
|
||||||
@@ -79,9 +80,10 @@ void PanelRenderer::renderHead(const Renderable* pRenderable, const RenderContex
|
|||||||
ostr << ",closable:false";
|
ostr << ",closable:false";
|
||||||
else
|
else
|
||||||
ostr << ",closeAction:'hide'";
|
ostr << ",closeAction:'hide'";
|
||||||
if (pPanel->isVisible())
|
if (pPanel->isVisible())
|
||||||
ostr << ",renderTo:Ext.getBody()";
|
ostr << ",renderTo:Ext.getBody()";
|
||||||
|
|
||||||
|
|
||||||
// minimizable set to true only fires a minimize event, without an event handler attached
|
// minimizable set to true only fires a minimize event, without an event handler attached
|
||||||
// it is pretty useless, instead use collapsible
|
// it is pretty useless, instead use collapsible
|
||||||
if (pPanel->showHeader())
|
if (pPanel->showHeader())
|
||||||
@@ -114,8 +116,80 @@ void PanelRenderer::renderHead(const Renderable* pRenderable, const RenderContex
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PanelRenderer::renderHeadWithoutChildren(const Panel* pPanel, const RenderContext& context, std::ostream& ostr)
|
||||||
|
{
|
||||||
|
ostr << "new Ext.Window({";
|
||||||
|
|
||||||
|
Utility::writeRenderableProperties(pPanel, ostr);
|
||||||
|
ostr << ",manager: winGrp";
|
||||||
|
if (!pPanel->getName().empty() && pPanel->showHeader())
|
||||||
|
ostr << ",title:'" << pPanel->getTitle() << "'";
|
||||||
|
if (pPanel->getWidth() > 0)
|
||||||
|
ostr << ",width:" << pPanel->getWidth();
|
||||||
|
else
|
||||||
|
ostr << ",width:100"; // required!
|
||||||
|
if (pPanel->getHeight() > 0)
|
||||||
|
ostr << ",height:" << pPanel->getHeight();
|
||||||
|
else
|
||||||
|
ostr << ",height:100"; // required!
|
||||||
|
if (pPanel->getModal())
|
||||||
|
ostr << ",modal:true";
|
||||||
|
if (!pPanel->hasCloseIcon())
|
||||||
|
ostr << ",closable:false";
|
||||||
|
else
|
||||||
|
ostr << ",closeAction:'hide'";
|
||||||
|
if (pPanel->isVisible())
|
||||||
|
ostr << ",renderTo:Ext.getBody()";
|
||||||
|
|
||||||
|
|
||||||
|
// minimizable set to true only fires a minimize event, without an event handler attached
|
||||||
|
// it is pretty useless, instead use collapsible
|
||||||
|
if (pPanel->showHeader())
|
||||||
|
ostr << ",header:true,maximizable:true,collapsible:true";
|
||||||
|
else
|
||||||
|
ostr << ",header:false";
|
||||||
|
|
||||||
|
if (!pPanel->enabled())
|
||||||
|
ostr << ",disabled:true";
|
||||||
|
|
||||||
|
ostr << "})";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void PanelRenderer::renderAsPanelChild(const Panel* pPanel, const RenderContext& context, std::ostream& ostr)
|
||||||
|
{
|
||||||
|
ostr << "new Ext.Panel({";
|
||||||
|
|
||||||
|
ostr << "border:false,bodyBorder:false,autoScroll:true";
|
||||||
|
View::Ptr pChild = pPanel->getChild();
|
||||||
|
if (pChild)
|
||||||
|
{
|
||||||
|
Layout::Ptr pLayout = pChild.cast<Layout>();
|
||||||
|
if (pLayout)
|
||||||
|
{
|
||||||
|
ostr << ",";
|
||||||
|
pLayout->renderHead(context, ostr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ostr << ",items:[";
|
||||||
|
pChild->renderHead(context, ostr);
|
||||||
|
ostr << "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ostr << "})";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PanelRenderer::renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
|
void PanelRenderer::renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
|
||||||
{
|
{
|
||||||
|
const Panel* pPanel = static_cast<const Poco::WebWidgets::Panel*>(pRenderable);
|
||||||
|
View::Ptr pChild = pPanel->getChild();
|
||||||
|
ostr << "<div id=\"p" << pPanel->id() << "\" />";
|
||||||
|
if (pChild)
|
||||||
|
pChild->renderBody(context, ostr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user