Results 1 to 2 of 2

Thread: validation logic and onBindAndValidate

  1. #1
    Join Date
    Sep 2004
    Location
    Boston, US
    Posts
    130

    Default validation logic and onBindAndValidate

    I have a web page with a table that is backed by a collection of domain objects. I need to enforce that the minDemand property of the bean is less than the maxDemand so in my controller, I test for this in my onBindAndValidate method :

    Code:
    if (minDemand > maxDemand)
    {
      errors.rejectValue("collection[" + i + "].minDemand", "bid.minDemandGTmaxDemand", "!The min demand should be less than or equal to the max demand!");
    }
    The form correctly displays the error however I noticed the invalid values of bean are persisted to the database. I'm using Hibernate and OSIV and when I think about it, this would happen as the binding of values to the hibernate managed beans has already taken place and the txn commits due to OSIV.

    This is not the desired behavior. How do I cause the invalid bean values to be rejected/not persisted? (Note : I cant use client side validation).

    Thanks,
    Sanjiv

  2. #2
    Join Date
    Sep 2004
    Location
    Boston, US
    Posts
    130

    Default

    I found out the cause for this. Details can be found in this thread

    http://forum.springframework.org/showthread.php?t=12637

    Sanjiv
    Last edited by robyn; May 14th, 2006 at 11:22 AM.

Similar Threads

  1. onBindAndValidate vs Validator
    By bobmanc in forum Web
    Replies: 1
    Last Post: Aug 17th, 2004, 09:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •