commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leandro Saad" <leandro.s...@gmail.com>
Subject [Validator] Not all validators executed
Date Fri, 05 May 2006 19:23:10 GMT
Hi all. I'm trying to get a better sense on how commons validator works. In
this example:

<!DOCTYPE form-validation PUBLIC
     "-//Apache Software Foundation//DTD Commons Validator Rules
Configuration 1.3.0//EN"
     "http://jakarta.apache.org/commons/dtds/validator_1_3_0.dtd">

<form-validation>
    <global>
        <validator    name="failsF1"
                    classname="
com.upstate.kinaseprofiler.commons.validator.FailsF1Validator"
                    method="isValid"
                    methodParams="java.lang.Object,
org.apache.commons.validator.Field"
                    msg="msg1"/>
        <validator    name="failsF2"
                    classname="
com.upstate.kinaseprofiler.commons.validator.FailsF2Validator"
                    method="isValid"
                    methodParams="java.lang.Object,
org.apache.commons.validator.Field"
                    msg="msg2"/>
    </global>
    <formset>
        <form name="testForm">
            <field    property="f1"
                    depends="failsF1, failsF2">
                <arg key="label.firstName"/>
            </field>

            <field     property="f2"
                    depends="failsF1, failsF2">
                <arg key="label.lastName"/>
            </field>
        </form>
    </formset>
</form-validation>

The validator FailsF2Validator is not executed for field f1. If you change
the depends attribute to: "failsF2, failsF1", the it gets executed. Here is
the stdout

1st Scenario:

f2
  action: failsF2 result: false valid: false
  action: failsF1 result: * valid: true
f1
  action: failsF1 result: false valid: false

2nd Scenario:

f2
  action: failsF2 result: false valid: false
  action: failsF1 result: * valid: true
f1
  action: failsF2 result: * valid: true
  action: failsF1 result: false valid: false

Do you have an explanation for this? I'm using 1.3.0
Also. When a validation fails, how do I get access to the error message. Is
it defined on attribute msg?

Cheers.

--
Leandro Rodrigo Saad Cruz
CTO - InterBusiness Technologies
db.apache.org/ojb
guara-framework.sf.net
xingu.sf.net

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message