Results 1 to 5 of 5

Thread: I want to get the access to request object in validator

  1. #1
    Join Date
    Dec 2011
    Posts
    2

    Question 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.

  2. #2
    Join Date
    May 2011
    Posts
    5

    Default

    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)

  3. #3

    Default

    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.

  4. #4
    Join Date
    Dec 2011
    Posts
    2

    Default

    I solved it with the help of RequestContextHolder using this I can access request object in any ordinary class.

  5. #5
    Join Date
    Jul 2008
    Location
    philippines
    Posts
    11

    Default

    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
  •