I am using SimpleFormController in my application to handle form submisions. one thing i am missing is the request object that is passed onSubmit(request,response..)
is a different one from the initial request object that is received by formBackingObject(..).probably because it is again a new request from web.
i just want to use the same parameters from request object in onSubmit(..) that i was able to access in formBackingObject(..).
it could be possible for me to store them in and pass thru hidden fields from jsp, but i am trying to get some elegant approach.
is there any way to achieve this?
EDIT:
i am overriding
formBackingObject(HttpServletRequest request)`
and
onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors)
methods in my class.
for the intial view formbackingObject(..) will be called and i will have some variables from the request object then if user submits the form onSubmit(..) will be called then i will have another request object which is different from the one i received in formbackingObject(..) .
what i am asking is, is there any way of holding the
initial ‘request’
parameters(request.getParameter() kind
of…) so that i can use them in
onSubmit(..) with out sending them
back & forth thru hidden fields ?’
The
formBackingObject()method is being called when the user makes the request for the initial form view. This is a completely separate HTTP request to when the user submits the form which is when theonSubmit()method is called.If you want to save state from the first HTTP request so it is available in the second HTTP request, your best option is probably to save it in the HTTP session.
eg: in your
formBackingObject()method:and in your
onSubmit()method: