You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Weber, Jeremy" <JW...@Eventra.com> on 2002/12/18 15:36:33 UTC

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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Simple Custom Validation Example Request

Posted by Rick Reumann <ma...@reumann.net>.
On Wednesday, December 18, 2002, 9:36:33 AM, Jeremy wrote:

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

    Well one thing I see right away is the package name is off. You
    are setting up the rule as : com.vs.install.util.VsValidate
    yet the class is set up as
    package com.vs.util.validate;

    Fix the validation part to call com.vs.util.validate.VsValidate
    and you should be all set.


-- 

Rick
mailto:maillist@reumann.net


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>