simplified table serializing

This commit is contained in:
Peter Schojer
2008-05-27 13:59:06 +00:00
parent e07a2126e9
commit d0a169567b
10 changed files with 74 additions and 193 deletions

View File

@@ -44,16 +44,6 @@ namespace WebWidgets {
namespace ExtJS {
ArrayTableSerializer::ArrayTableSerializer()
{
}
ArrayTableSerializer::~ArrayTableSerializer()
{
}
void ArrayTableSerializer::serialize(std::ostream& ostr, const Table* pTable, std::size_t rowBegin, std::size_t rowCntUser)
{
//[
@@ -119,7 +109,7 @@ void ArrayTableSerializer::serialize(std::ostream& ostr, const Table* pTable, st
}
const std::string& ArrayTableSerializer::contentType() const
const std::string& ArrayTableSerializer::contentType()
{
static const std::string ct("text/javascript");
return ct;

View File

@@ -38,10 +38,12 @@
#include "Poco/WebWidgets/ExtJS/FormRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/ExtJS/TableCellHandlerFactory.h"
#include "Poco/WebWidgets/ExtJS/ArrayTableSerializer.h"
#include "Poco/WebWidgets/Table.h"
#include "Poco/WebWidgets/WebApplication.h"
#include "Poco/WebWidgets/RequestHandler.h"
#include "Poco/WebWidgets/DateFormatter.h"
#include "Poco/Delegate.h"
#include <sstream>
@@ -146,7 +148,9 @@ void TableRenderer::renderProperties(const Table* pTable, const RenderContext& c
ostr << ",height:" << pTable->getHeight();
ostr << ",store:";
renderStore(pTable, ostr);
WebApplication::instance().registerAjaxProcessor(Poco::NumberFormatter::format(id), const_cast<Table*>(pTable));
Table* pT = const_cast<Table*>(pTable);
pT->beforeLoad += Poco::delegate(&TableRenderer::onBeforeLoad);
WebApplication::instance().registerAjaxProcessor(Poco::NumberFormatter::format(id), pT);
}
@@ -258,5 +262,13 @@ void TableRenderer::renderStore(const Table* pTable, std::ostream& ostr)
}
void TableRenderer::onBeforeLoad(void* pSender, Table::LoadData& ld)
{
ld.pResponse->setChunkedTransferEncoding(true);
ld.pResponse->setContentType(ArrayTableSerializer::contentType());
std::ostream& out = ld.pResponse->send();
ArrayTableSerializer::serialize(out, ld.pTable, ld.firstRow, ld.rowCnt);
}
} } } // namespace Poco::WebWidgets::ExtJS