Yes. I have validation working correctly. Required and mask works good. And
my validator method gets called and returns false, but I do not add any
errors message is it necessary?

On 10/26/07, Laurie Harper <[EMAIL PROTECTED]> wrote:
>
> John Doe wrote:
> > 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?
>
> Do you have the standard validation working correctly? I.e. if you
> remove uniqueGroupId are the required and mask validators applied
> correctly? Have you confirmed that your custom validation method gets
> called? What happens if you have it add a validation error message as
> well as return false?
>
> L.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
Best regards,
Bashmaкov Anton

Reply via email to