To give the user the chance to review and confirm what he has entered into a form, show him the data on a confirmation page. Provide two buttons on this page either to accept or to cancel the final submission.
[[#wd DisplayAnythingRenderer { /AnythingInfo { "bool MyCheckFormAction::DoAction(String &action, Context &c)" "{" " Anything query = c.GetQuery();" " Anything fields = query["fields"];" " " " // code to handle the input" " // store the content of the fields in the role store for later use" " Anything rs = c.GetRoleStore();" " for(int i= 0; i < fields.GetSize(); i++) {" " // all the fields should be stored directly, because Context.Lookup cannot find" " // MyFormData.MyFirstField -- May an idea to provide this behaviour" " rs[fields.SlotName(i)]= fields[i];" " }" " // launch confirmation page" " action = "MyCheckFormAction";" " return true;" "}" } }]]
Include as well a new FormRenderer that renders the two buttons. Check recipe 6 to learn more about using FormRenderer. Because the FormRenderer uses HTML-Templates you can render the field values directly there.
[[#wd DisplayAnythingRenderer { /AnythingInfo { "/ConfirmationForm {" " /Form {" " /Method "GET"" " /Action "MyConfirmationAction"" " /Template {" " "You have entered:" " "<p>My first field :[[ #wd Lookup { /ContextLookupName MyFirstField } ]]" " "<p>My second field :[[ #wd Lookup { /ContextLookupName MySecondField } ]]" " ...." " "<p>[[#wd Lookup OkButtonRenderer ]] [[#wd Lookup CancelButtonRenderer ]]" " }" " }" "}" } }]] [[#wd DisplayAnythingRenderer { /AnythingInfo { "/OkButtonRenderer {" " /Button {" " /Name "OkButton"" " /Label {" " /String {" " /Default "I confirm"" " }" " }" " }" "}" } }]] [[#wd DisplayAnythingRenderer { /AnythingInfo { "/CancelButtonRenderer {" " /Button {" " /Name "CancelButton"" " /Label {" " /String {" " /Default "Cancel"" " }" " }" " }" "}" } } ]]
[[#wd DisplayAnythingRenderer { /AnythingInfo { "bool MyConfirmationAction::DoAction(String &action, Context &c)" "{" " Anything query = c.GetQuery();" " Anything fields = query["fields"];" " " " // check if Ok button was pressed" " if (fields.IsDefined("OkButton") {" " // Retrieve the fields from the Rolestore" " ROAnything rs = c.GetRoleStore();" " " " // ... and perform what you like to do in the Ok case" " String firstFirst = rs["MyFirstField"].AsString(""); // just for fun" " String secondFirst = rs["MySecondField"].AsString(""); // just for fun" " " " action = "InputOk";" " return true;" " }" " // the else case could return another "action"." "}" } } ]]
[[#wd DisplayAnythingRenderer { /AnythingInfo { "/Actions {" " /MyFormAction {" " "MyForm"" " }" " /MyConfirmationAction {" " "ConfirmationForm"" " }" " " " ... other Actions" "}" } }]]