Now, on the web, simply calling the
submit() method of your form object performs a POST request back to the server with all the form data. Overriding the
onSubmit() event of the form object with your own code and a return value of true or false will either prevent or allow the
submit() to occur, much the same way that the
Querysave event of a Notes form can be made to arrest the save event by setting the continue parameter variable to false. While this parallelism is striking, the caveat is that you cannot directly call the
@Command([FileSave]). On the web, this will fire the
submit() event of the form which will in turn fire the
onSubmit() event, calling our code and affecting the execution of the
save() event based upon its return value (true or false.) In the Notes client, the same thing will happen, except for one important difference: On the web, a submit intrinsically results in a new URL being loaded, which can be served up to the browser from a
$$Return field (old school) or a
Webquerysave agent. In the Notes client, however, the open form will not close. Simple, you say? just add a
@Command([FileCloseWindow]) to the macro? Well, that will result in the user being prompted if they want to save their changes in the Notes UI –not exactly desired behavior after all our validation ran. The answer, again, is an old-school trick of using the
Postsave Notes form event to force the close:
- Sub Postsave(Source As Notesuidocument)
- source.Document.SaveOptions = 0
- Call source.Close
- End Sub
Setting the reserved field “SaveOptions” to zero (note that the field does not have to be present in the form and in fact will present less of a problem if it isn’t) tells the Notes client that the user shouldn't be prompted to save the changes made, which is desirable to use as we’ve already just saved the document.
With new technologies come new possibilities. This is a double edge sword. Those expecting XPages development to be a simple one-to-one mapping of functionality from current Notes dev practice will be shocked. The strict binding of controls to documents is gone, as is the relative simplicity that comes from what is -after all- a very simplistic development model. The depth and complexity of XPages may be daunting, but it does represent the future of Notes.
As always, feedback is appreciated.