Still no go.  I had some problems with my package paths etc., but that wasnt
the cause either.  The default validations do work but do I need to do
anything else in struts-config.xml?


Thanks


Jeremy

-----Original Message-----
From: Alireza Fattahi [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, December 18, 2002 10:33 AM
To: 'Struts Users Mailing List'
Subject: RE: Simple Custom Validation Example Request


Here is sample.

Hope it helps. One question are default validations like required working?
If not check your struts_config.xml.

Validation_rule.xml:

<validator name="preciseEmail"
  classname="com.sgccir.struts.validations.EmailValidator"
  method="isEmail"
  methodParams="java.lang.Object,
    org.apache.commons.validator.ValidatorAction,
    org.apache.commons.validator.Field,
    org.apache.struts.action.ActionErrors,
    javax.servlet.http.HttpServletRequest"
  msg="errors.email" />



validation.xml
  <form name="CommentVwcredForm">
    <field property="email" depends="preciseEmail">
      <arg0 key="label.email" />
      <var>
        <var-name>mask</var-name>
        <var-value>^[a-zA-Z]*$</var-value>
      </var>
    </field>
  </form>



public static boolean isEmail( java.lang.Object bean,
 
org.apache.commons.validator.ValidatorAction va,
                                 org.apache.commons.validator.Field field,
                                 org.apache.struts.action.ActionErrors
errors,
                                 javax.servlet.http.HttpServletRequest
request ) {
    log.trace( "In isEmail() method" );

    boolean blIsValidEmail = true;
..........

}


-----Original Message-----
From: Weber, Jeremy [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, December 18, 2002 6:07 PM
To: 'Struts Users Mailing List' (E-mail)
Subject: Simple Custom Validation Example Request

Could someone post the very simplest example of some custom validation code.
I am still having problems with my code as explained in previous post below.
Maybe if I start of smaller I could make some sense of whats going on. 



Thanks,


Jeremy


Im trying to start of simple with a custom validaton method.  Currently all
it contains is a system.out to verify that the method never gets called. Can
some one verify that my configuration is correct?  I would appreciate it.


validator-rules.xml

      <validator name="identical"
                 classname="com.vs.install.util.VsValidate"
                 method="validateIdentical"
                 methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionErrors,
                       javax.servlet.http.HttpServletRequest"

                 depends="required"
                 msg="errors.identical"
        />


validation.xml
        <form    name="SetupFormBean">
                        <field    property="vsynchNum"
                                depends="required,integer">
                                <arg0
key="newinstall.vsynchnum.displayname"/>
                        </field>
                        <field    property="vsappNum"
                                depends="required,integer,identical">
                                <arg0
key="newinstall.vsappnum.displayname"/>
                        </field>
                        <field    property="installDir"
                                  depends="required">
                                  <arg0
key="newinstall.installdir.displayname"/>

                        </field>
                </form>

package com.vs.util.validate;

import java.io.Serializable;
import java.util.Locale;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.commons.validator.Field;
import org.apache.commons.validator.GenericValidator;
import org.apache.commons.validator.ValidatorAction;
import org.apache.commons.validator.ValidatorUtil;
import org.apache.struts.util.StrutsValidatorUtil;
import java.text.*;
import java.util.*;

public final class VsValidate implements Serializable  {

        public VsValidate() {
        }


        public static boolean validateIdentical(Object bean, ValidatorAction
va, Field field, ActionErrors errors, HttpServletRequest request){
               System.out.println("entered method");

                return true;
        }



}




--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to