I'm trying to set up an MVC controller that will initialize the underlying command ONLY when a new form is displayed.
Basically, the user arrives at the "edit" page for an image gallery by specifying a request parameter like "galleryId". Within the page, I have a bunch of filters the user can set using SELECT lists, etc. These controls are bound to the underlying command, but the list of images being displayed as a result of the command is just placed in the request attributes by the controller.
So I want the controller to initialize the command when it sees a request for a new form, and initialize the image list based on the value of the "galleryId" parameter. On subsequent post-backs (such as when the user filters the list of images by submitting the underlying command), I want the controller to take the existing command, and "re-generate" the image list.
I'm trying to use a combination of formBackingObject, to initialize the command when a new form is requested, and onSubmit(request, response, Object, BindException) when the user submits a filter parameter on subsequent post-backs. But formBackingObject is called on every request, so this approach is not working at all.
How the heck can I do this? I know it seems like the most basic question, but every Spring MVC tutorial I can google seems to deal with Kindergarten-level application examples, and none of them has any kind of parallel to this functionality (select a gallery from a list, proceed to a "view" page for the gallery, filter the "gallery view", proceed to a "view" page for an image, etc. Basic hierarchical stuff).