mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-21 14:42:51 +01:00
fixed events
This commit is contained in:
parent
b1c5c8b484
commit
4d95e3bf49
@ -43,6 +43,7 @@
|
||||
#include "Poco/WebWidgets/Form.h"
|
||||
#include "Poco/WebWidgets/WebApplication.h"
|
||||
#include "Poco/WebWidgets/RequestHandler.h"
|
||||
#include "Poco/NumberFormatter.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@ -131,6 +132,8 @@ void TextFieldCellRenderer::writeCellProperties(const TextFieldCell* pCell, std:
|
||||
ostr << "}"; // close listeners
|
||||
}
|
||||
|
||||
if (pOwner)
|
||||
WebApplication::instance().registerAjaxProcessor(Poco::NumberFormatter::format(pOwner->id()), const_cast<TextFieldCell*>(pCell));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "Poco/WebWidgets/ToggleButtonCell.h"
|
||||
#include "Poco/WebWidgets/ToggleButton.h"
|
||||
#include "Poco/WebWidgets/RequestHandler.h"
|
||||
#include "Poco/NumberFormatter.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@ -101,6 +102,10 @@ void ToggleButtonCellRenderer::renderProperties(const ToggleButtonCell* pToggleB
|
||||
{
|
||||
WebApplication::instance().registerFormProcessor(pToggleButtonCell->getOwner()->getName(), const_cast<ToggleButtonCell*>(pToggleButtonCell));
|
||||
}
|
||||
if (pButton)
|
||||
{
|
||||
WebApplication::instance().registerAjaxProcessor(Poco::NumberFormatter::format(pButton->id()), const_cast<ToggleButtonCell*>(pToggleButtonCell));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -92,6 +92,8 @@ public:
|
||||
// Cell
|
||||
void handleForm(const std::string& field, const std::string& value);
|
||||
|
||||
void handleAjaxRequest(const Poco::Net::NameValueCollection& args, Poco::Net::HTTPServerResponse& response);
|
||||
|
||||
bool serializeJSON(std::ostream& out, const std::string& name);
|
||||
|
||||
protected:
|
||||
|
@ -77,6 +77,7 @@ public:
|
||||
// Cell
|
||||
void handleForm(const std::string& field, const std::string& value);
|
||||
|
||||
void handleAjaxRequest(const Poco::Net::NameValueCollection& args, Poco::Net::HTTPServerResponse& response);
|
||||
|
||||
bool serializeJSON(std::ostream& out, const std::string& name);
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
|
||||
#include "Poco/WebWidgets/TextFieldCell.h"
|
||||
#include "Poco/WebWidgets/TextField.h"
|
||||
#include "Poco/WebWidgets/RequestHandler.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@ -86,12 +87,26 @@ void TextFieldCell::handleForm(const std::string& field, const std::string& valu
|
||||
{
|
||||
Poco::Any newValue = getFormatter()->parse(value);
|
||||
ValueChange vc(getFormatter(), getValue(), newValue);
|
||||
setValue(value);
|
||||
setValue(newValue);
|
||||
textChanged.notify(this, vc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TextFieldCell::handleAjaxRequest(const Poco::Net::NameValueCollection& args, Poco::Net::HTTPServerResponse& response)
|
||||
{
|
||||
const std::string& ev = args[RequestHandler::KEY_EVID];
|
||||
if (ev == EV_TEXTCHANGED)
|
||||
{
|
||||
Formatter::Ptr pForm = getFormatter();
|
||||
handleForm("", args[FIELD_NEWVAL]);
|
||||
response.send();
|
||||
}
|
||||
else
|
||||
response.send();
|
||||
}
|
||||
|
||||
|
||||
bool TextFieldCell::serializeJSON(std::ostream& out, const std::string& name)
|
||||
{
|
||||
out << name << ":";
|
||||
|
@ -77,7 +77,6 @@ void TimeFieldCell::setFormat(TimeField::Format fmt)
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool TimeFieldCell::serializeJSON(std::ostream& out, const std::string& name)
|
||||
{
|
||||
out << name << ":";
|
||||
|
@ -36,6 +36,7 @@
|
||||
|
||||
#include "Poco/WebWidgets/ToggleButtonCell.h"
|
||||
#include "Poco/WebWidgets/BoolFormatter.h"
|
||||
#include "Poco/WebWidgets/RequestHandler.h"
|
||||
#include "Poco/String.h"
|
||||
|
||||
|
||||
@ -101,4 +102,21 @@ bool ToggleButtonCell::serializeJSON(std::ostream& out, const std::string& name)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ToggleButtonCell::handleAjaxRequest(const Poco::Net::NameValueCollection& args, Poco::Net::HTTPServerResponse& response)
|
||||
{
|
||||
const std::string& ev = args[RequestHandler::KEY_EVID];
|
||||
if (ev == EV_CHECKED)
|
||||
{
|
||||
bool check = false;
|
||||
if (args[FIELD_VAL] == "true")
|
||||
check = true;
|
||||
setChecked(check);
|
||||
|
||||
response.send();
|
||||
}
|
||||
else
|
||||
response.send();
|
||||
}
|
||||
|
||||
} } // namespace Poco::WebWidgets
|
||||
|
Loading…
x
Reference in New Issue
Block a user