Hi,
finish() is defined in LiftScreen as follows:
protected def finish(): Unit
protected def doFinish(): JsCmd = {
validate match {
case Nil =>
val snapshot = createSnapshot
PrevSnapshot.set(Full(snapshot))
finish()
redirectBack()
case xs => {
S.error(xs)
if (ajaxForms_?) {
SetHtml(FormGUID, renderHtml())
} else {
Noop
}
}
}
}
To answer your question: finish() doesn't return anything, so you cannot return errors. Errors have to be returned during validation. If no validation errors occur, then finish() and redirectBack() are called.
If anything happens during finish() (e.g. concurrent modification error from the database), you can try to work around that in redirectBack():
protected def redirectBack(): JsCmd = {
if (ajaxForms_?) {
AjaxOnDone.get
} else {
S.seeOther(Referer.get)
}
}
If you use AJAX, then you can simply send JS commands, e.g. exchange an area of HTML and display a success message, or send a redirect. If you set AjaxOnDone to a JS no-op, then nothing happens. I.e. the user stays on the form. (Though I don't know if there are any negative side effects happening during the finish process such that it would not be a good idea to stay on the form ...) I.e. in the case of an error during finish() you can set AjaxOnDone to a noop.
For non-AJAX forms you would have to override redirectBack() or doFinish() to circumvent redirecting after errors in finish().
If you want to have more freedom in you form layout you should definitely take a look at
https://github.com/pbrant/lift-liftscreen-css-binding. I'm using it for my LiftScreens and it works great.
Best regards
Soeren