mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-23 00:07:59 +02:00
onsuccess suport for form loading
This commit is contained in:
@@ -70,7 +70,7 @@ public:
|
|||||||
static std::string formVariableName(const Form* pForm);
|
static std::string formVariableName(const Form* pForm);
|
||||||
/// Creates the variable name for the form
|
/// Creates the variable name for the form
|
||||||
|
|
||||||
static Poco::WebWidgets::JSDelegate createReloadFunction(const std::string& fctName, const Form* pForm);
|
static Poco::WebWidgets::JSDelegate createReloadFunction(const std::string& fctName, const Form* pForm, const std::string& onSuccess="", const std::string& failure="");
|
||||||
/// Creates a function with the given fctName (can be empty) that reloads the form
|
/// Creates a function with the given fctName (can be empty) that reloads the form
|
||||||
/// E.g.: add the returned JSDelegate to pReload->buttonClicked
|
/// E.g.: add the returned JSDelegate to pReload->buttonClicked
|
||||||
};
|
};
|
||||||
|
@@ -101,7 +101,7 @@ std::string FormRenderer::formVariableName(const Form* pForm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Poco::WebWidgets::JSDelegate FormRenderer::createReloadFunction(const std::string& fctName, const Form* pForm)
|
Poco::WebWidgets::JSDelegate FormRenderer::createReloadFunction(const std::string& fctName, const Form* pForm, const std::string& onSuccess, const std::string& onFailure)
|
||||||
{
|
{
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
out << "function ";
|
out << "function ";
|
||||||
@@ -109,7 +109,13 @@ Poco::WebWidgets::JSDelegate FormRenderer::createReloadFunction(const std::strin
|
|||||||
out << "var theForm = Ext.getCmp('" << pForm->id() << "');" << std::endl;
|
out << "var theForm = Ext.getCmp('" << pForm->id() << "');" << std::endl;
|
||||||
out << "var uri = '" << pForm->getURI().toString() << "/;" << RequestHandler::KEY_EVID << "=" << Form::EV_RELOAD << "&";
|
out << "var uri = '" << pForm->getURI().toString() << "/;" << RequestHandler::KEY_EVID << "=" << Form::EV_RELOAD << "&";
|
||||||
out << RequestHandler::KEY_ID << "=" << pForm->id() << "';" << std::endl;
|
out << RequestHandler::KEY_ID << "=" << pForm->id() << "';" << std::endl;
|
||||||
out << "theForm.load({url:uri,method:'GET'});" << std::endl; // success, failure handlers
|
out << "theForm.load({" << std::endl;
|
||||||
|
out << "url:uri,method:'GET'" << std::endl;
|
||||||
|
if (!onSuccess.empty())
|
||||||
|
out << ",success: " << onSuccess << std::endl;
|
||||||
|
if (!onFailure.empty())
|
||||||
|
out << ",failure: " << onFailure << std::endl;
|
||||||
|
out << "});" << std::endl; // success, failure handlers
|
||||||
out << "}" << std::endl;
|
out << "}" << std::endl;
|
||||||
return jsDelegate(out.str());
|
return jsDelegate(out.str());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user