Handling required arguments in form controller during GET
I have a form controller (which extends SimpleFormController) which is passed an Id parameter during the get request. (for example, http://.../myapp/myobject/edit.html?id=120). The form is expected to retrieve the object from database using Id and return it as command object for editing. When the object is returned during submission, the controller updates the data in the database.
If the id parameter is missing during edit request or there is some problem accessing the requested object (because it does not exist in database or due to some access restriction in the business layer), I would like to return the user back to the page where he was (and he could be doing this from multiple places in the application) with an error message.
What is the right way to do this? Is there a best practice to accomplish this.
I just started using Spring a week back and I appreciate your help.
Thanks in advance.