Give status update from a Spring controller method before actually returning -
i have 3 endpoints in web application, /overview
, /insert
, , /update
. @ /insert
user can specify data , submit /update
data processed. in /overview
user can see status.
the /update
consists of 2 steps: verification , doing update. when verification fails user redirected again /insert
change data. when verification successful, user redirected /overview
see updated data. code this:
@requestmapping(value = "/update", method = {requestmethod.post}) public modelandview processdata(modelmap model, @requestparam(value = "data", required = true) string data) { // verification, needs time boolean verificationfailed = verify(data); // in case of failed verification, return insert page if (verificationfailed) { return new modelandview("insert", model); } // todo: send udpate web page // perform action dosomething(data); // redirect overview page see effects return new modelandview("redirect:/overview", model); }
the process needs time verification , actual processing (a few seconds, half minute each). give user update after successful verification, such website can updated link /overview
user can click if suspects timeout.
the 2 steps verification/processing should launched 1 click user, assumed verification typically successful.
Comments
Post a Comment