Announcement Announcement Module
Collapse
No announcement yet.
Validator and sessions Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Validator and sessions

    Hi All

    I was courious why the spring framework doesnt supply any option what so ever that will allow me access the HttpSession in a validator.

    The thing is, I need to access a user object in the session so that I can get the users Locale. I need to get that Locale so that I can verify that the inputed date string confirms to that users locale. For example:

    America MM-dd-yyyy
    Europe dd-MM-yyyy

    I could put the locales identifier string in the command bean but then I need to regenerate the locale from that string. That is too much overhead. If only I had access to the session my code would be nice and cleaner than putting such things in the command bean.

    Has anybody got an idea how to get the session in a validator?

    Thanks in advance,
    Martyn

  • #2
    I was courious why the spring framework doesnt supply any option what so ever that will allow me access the HttpSession in a validator.
    The Validation framework supplied with Spring isn't based on the Spring MVC framework. You can perfectly well use it WITHOUT Spring MVC or even a web layer. Making it dependend on the HttpSession would limit the usability.

    We use a ServletFilter which retrieves an Object from the request/session puts in in a ThreadLocal and that way we can access it from everywhere. Acegi uses the same solution for the SecurityContext.

    Comment

    Working...
    X