Results 1 to 2 of 2

Thread: Validation of checkbox using Commons validation

Hybrid View

  1. #1

    Default Validation of checkbox using Commons validation

    We are using commons validation from spring modules and works great for text fields. But, when we use it for checkboxes, it doesn't seem to work.

    In the validation.xml, we have the following entry
    <field property="agreedLegalPolicy" depends="required">
    <msg name="required" key="error.legalnotchecked" />
    </field>

    In our command object the agreedLegalPolicy is a boolean field.

    Tracing the code using a debugger, it looks like the required check always succeed since the boolean is initialized to false when the checkbox is not checked.

    Any thoughts on how this should work will be appreciated. The alternative I am considering is to use a custom validation class or override the onBindAndValidate of the form controller to perform custom validation.

    Thanks.

  2. #2
    Join Date
    Apr 2009
    Posts
    1

    Default

    I'm sure you've found a workaround in the past 3 years, but for the sake of others who find this thread:

    The best solution I found was to create a custom Commons Validator validator for "booleanValue." You supply either "true" or "false" as a var to the validation rule, and then it checks to make sure your field is the same value.

Similar Threads

  1. Replies: 4
    Last Post: Mar 12th, 2010, 12:28 PM
  2. Commons Validator Serverside Validation
    By MartyJones in forum Web
    Replies: 2
    Last Post: Dec 21st, 2005, 06:54 PM
  3. Spring and commons validation
    By jkookie in forum Web
    Replies: 6
    Last Post: Sep 23rd, 2005, 12:41 PM
  4. Replies: 5
    Last Post: Apr 27th, 2005, 07:04 PM
  5. Commons validation with wizard form controller
    By brianstclair in forum Web
    Replies: 0
    Last Post: Jan 14th, 2005, 02:14 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
  •