Fixed the value of AutoConnectElements not reflected. Issue #64

pull/68/head
Hieromon Ikasamo 6 years ago
parent 7f392c0657
commit 1f7e7ddb9f
  1. 1
      README.md
  2. 28
      src/AutoConnect.cpp
  3. 24
      src/AutoConnectAux.cpp

@ -104,6 +104,7 @@ Full documentation is available on https://Hieromon.github.io/AutoConnect, some
- Supports new element type **AutoConnectFile** and built-in file uploader. - Supports new element type **AutoConnectFile** and built-in file uploader.
- Supports a **format attribute** with the AutoConnectText element. - Supports a **format attribute** with the AutoConnectText element.
- Fixed blank page responds with Configure new. - Fixed blank page responds with Configure new.
- Fixed the value of AutoConnectElements not reflected.
- Changed menu labels placement in source files structure. - Changed menu labels placement in source files structure.
### [0.9.7] Feb. 25, 2019 ### [0.9.7] Feb. 25, 2019

@ -794,20 +794,20 @@ bool AutoConnect::_classifyHandle(HTTPMethod method, String uri) {
// If the current request argument contains AutoConnectElement, it is // If the current request argument contains AutoConnectElement, it is
// the form data of the AutoConnectAux page and with this timing save // the form data of the AutoConnectAux page and with this timing save
// the value of each element. // the value of each element.
if (_webServer->hasArg(String(F(AUTOCONNECT_AUXURI_PARAM)))) { // if (_webServer->hasArg(String(F(AUTOCONNECT_AUXURI_PARAM)))) {
_auxUri = _webServer->arg(AUTOCONNECT_AUXURI_PARAM); // _auxUri = _webServer->arg(AUTOCONNECT_AUXURI_PARAM);
_auxUri.replace("/", "/"); // _auxUri.replace("/", "/");
AutoConnectAux* aux = _aux.get(); // AutoConnectAux* aux = _aux.get();
while (aux) { // while (aux) {
if (aux->_uriStr == _auxUri) { // if (aux->_uriStr == _auxUri) {
// Save the value owned by each element contained in the POST body // // Save the value owned by each element contained in the POST body
// of a current HTTP request to AutoConnectElements. // // of a current HTTP request to AutoConnectElements.
aux->_storeElements(_webServer.get()); // aux->_storeElements(_webServer.get());
break; // break;
} // }
aux = aux->_next.get(); // aux = aux->_next.get();
} // }
} // }
// Here, classify requested uri // Here, classify requested uri
if (uri == _uri) { if (uri == _uri) {

@ -370,6 +370,28 @@ const String AutoConnectAux::_indicateEncType(PageArgument& args) {
const String AutoConnectAux::_insertElement(PageArgument& args) { const String AutoConnectAux::_insertElement(PageArgument& args) {
String body = String(""); String body = String("");
// When WebServerClass::handleClient calls RequestHandler, the parsed
// http argument has been prepared.
// If the current request argument contains AutoConnectElement, it is
// the form data of the AutoConnectAux page and with this timing save
// the value of each element.
WebServerClass* _webServer = _ac->_webServer.get();
if (_webServer->hasArg(String(F(AUTOCONNECT_AUXURI_PARAM)))) {
_ac->_auxUri = _webServer->arg(String(F(AUTOCONNECT_AUXURI_PARAM)));
_ac->_auxUri.replace("/", "/");
AutoConnectAux* aux = _ac->_aux.get();
while (aux) {
if (aux->_uriStr == _ac->_auxUri) {
// Save the value owned by each element contained in the POST body
// of a current HTTP request to AutoConnectElements.
aux->_storeElements(_webServer);
break;
}
aux = aux->_next.get();
}
}
// Call user handler before HTML generation.
if (_handler) { if (_handler) {
if (_order & AC_EXIT_AHEAD) { if (_order & AC_EXIT_AHEAD) {
AC_DBG("CB in AHEAD %s\n", uri()); AC_DBG("CB in AHEAD %s\n", uri());
@ -377,9 +399,11 @@ const String AutoConnectAux::_insertElement(PageArgument& args) {
} }
} }
// Generate HTML for all AutoConnectElements contained in the page.
for (AutoConnectElement& addon : _addonElm) for (AutoConnectElement& addon : _addonElm)
body += addon.toHTML(); body += addon.toHTML();
// Call user handler after HTML generation.
if (_handler) { if (_handler) {
if (_order & AC_EXIT_LATER) { if (_order & AC_EXIT_LATER) {
AC_DBG("CB in LATER %s\n", uri()); AC_DBG("CB in LATER %s\n", uri());

Loading…
Cancel
Save