-
Dec 12th, 2011, 12:07 AM
#1
I want to get the access to request object in validator
I need to use request object to get some information and session details too. in validator in spring without passing it into argument.
any kind of context or something that can give me request object?
any pointers or solution are appritiated
waiting for answers or hint pls
Regards
Vishal
Last edited by vkpardava; Dec 12th, 2011 at 12:45 AM.
-
Dec 12th, 2011, 05:10 AM
#2
The validate method on your validator class takes an input an object to be validated (typically your form object). One way is to provide a setter on this form object to the HttpRequest. You can obtain reference from the HttpRequest from your controller handler method (see http://static.springsource.org/sprin...ping-arguments)
-
Dec 12th, 2011, 12:40 PM
#3
I would design your application so that your validators don't depend on HTTP at all. This is not a good coupling. If you need to do this, you're probably doing it wrong.
-
Dec 12th, 2011, 11:49 PM
#4
I solved it with the help of RequestContextHolder using this I can access request object in any ordinary class.
-
Jan 23rd, 2012, 02:58 PM
#5
But can we used Validator on a non-MVC environment? like stand alone app.. Any tutorials on this?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules