summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/controllerfunctions.lua5
-rw-r--r--lib/viewfunctions.lua17
2 files changed, 21 insertions, 1 deletions
diff --git a/lib/controllerfunctions.lua b/lib/controllerfunctions.lua
index 23e57d4..53ef927 100644
--- a/lib/controllerfunctions.lua
+++ b/lib/controllerfunctions.lua
@@ -1,6 +1,6 @@
module(..., package.seeall)
-function handle_form(self, getFunction, setFunction, clientdata, option, label, descr)
+function handle_form(self, getFunction, setFunction, clientdata, option, label, descr, redirectOnSuccess)
local form = getFunction()
if clientdata[option] then
@@ -25,6 +25,9 @@ function handle_form(self, getFunction, setFunction, clientdata, option, label,
form.descr = descr
end
form = self:redirect_to_referrer(form)
+ if redirectOnSuccess and not form.errtxt then
+ self:redirect(redirectOnSuccess)
+ end
else
form = self:redirect_to_referrer() or form
end
diff --git a/lib/viewfunctions.lua b/lib/viewfunctions.lua
index 27320a6..45701d6 100644
--- a/lib/viewfunctions.lua
+++ b/lib/viewfunctions.lua
@@ -171,3 +171,20 @@ function displayform(myform, order)
io.write('</DL>\n')
io.write('</FORM>')
end
+
+function displaycommandresults(commands, session)
+ local cmdresult = {}
+ for i,cmd in ipairs(commands) do
+ if session[cmd.."result"] then
+ cmdresult[#cmdresult + 1] = session[cmd.."result"]
+ session[cmd.."result"] = nil
+ end
+ end
+ if #cmdresult > 0 then
+ io.write("<H1>Command Result</H1>\n<DL>\n")
+ for i,result in ipairs(cmdresult) do
+ io.write(result.value:gsub("\n", "<BR>") .. "\n")
+ end
+ io.write("</DL>\n")
+ end
+end