Hi,
I have Struts 1.2.7 application and I need to write custom validator for my
form. I've wrote struts tutorial at
 http://struts.apache.org/1.2.7/userGuide/dev_validator.html
and have tried to do the same. But my validator is not working. Here is my
class method :

public class GroupIdValidator {

    public static boolean checkGroupId(Object bean, Field field,
HttpServletRequest request) {

        return false;
    }

as you can see it's just the test method, than always returns FALSE. And
here is my validation-rules.xml :

        <validator name="uniqueGroupId"
                   classname="com.mysite.validators.GroupIdValidator"
                   method="checkGroupId"
                   msg="errors.groupid.unique"
                   methodParams="java.lang.Object,
                       org.apache.commons.validator.Field,
                       javax.servlet.http.HttpServletRequest"
                   depends="required"
                />

and validation.xml for my form :

        <form name="addGroupForm">
            <field property="id" depends="required,mask,uniqueGroupId">
                <arg0 key="formGroup.groupName"/>
                <msg name="mask" key="errors.mask" />
                <arg1 key="mask.devicegroupid" resource="true"/>
                <var>
                    <var-name>mask</var-name>
                    <var-value>^[a-zA-Z0-9_]*$</var-value>
                </var>
            </field>

Every thing looks great, but when I submit my form it passes validation
(when uniqueGroupId always return false)! It seems like my validator returns
true. The strange thing is that my validation method calls and works normaly
and it should always fail field validation.
What is wrong with my custom pluggable validator?

-- 
Best regards,
Bashmaкov Anton

Reply via email to