You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Kamholz, Keith (corp-staff) USX" <kk...@moog.com> on 2003/08/01 18:40:17 UTC

NoSuchMethodException

Hey everyone,
I'm working on a custom validator right now, and all the validation method
does is return false.  That means it fails that validation, right?
Anyway, when I submit the form, I get a NoSuchMethod error.  What would
cause this?  All of my regular validations work, just not this custom one.
Here are some code snippets.  Thanks in advance for any help!

public class CustomValidator implements Serializable 
{
	public static boolean validateRange(Object bean, ValidatorAction va,

					Field field, ActionErrors errors,
HttpServletRequest request)
	{
		return false;
	}
}


validator-rules.xml:

   	  <!-- Custom Validators -->
      
      <validator name="validRange"
            classname="com.moog.us.app.ans.validation.CustomValidator"
               method="validateRange"
         methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionErrors,
                       javax.servlet.http.HttpServletRequest,
                       javax.servlet.ServletContext"
                  msg="errors.invalid.range">
      </validator>


And parts of my validation.xml:

    <global>

    </global>

		<form name="/AddAssignment">
		   	<field	property="startRange"
		   			depends="required">
		   			<arg0 key="app.label.startRange"/>
		   	</field>
	   		<field	property="endRange"
		   			depends="validRange">
		   	</field>
		</form>




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: NoSuchMethodException

Posted by Yansheng Lin <ya...@isogis.com>.
I can see there are several issues here.  First I think you might want to supply
the ServletContext as well.  Second, you want to add the error to Errors
collection by adding:
	errors.add(field.getKey(), ValidatorUtil.getActionError(servletContext,
request, va, field));
before the return statement. 

Try it.  I spent a lot of time before on this too.


-----Original Message-----
From: Kamholz, Keith (corp-staff) USX [mailto:kkamholz@moog.com] 
Sent: August 1, 2003 10:40 AM
To: Struts (E-mail)
Subject: NoSuchMethodException


Hey everyone,
I'm working on a custom validator right now, and all the validation method
does is return false.  That means it fails that validation, right?
Anyway, when I submit the form, I get a NoSuchMethod error.  What would
cause this?  All of my regular validations work, just not this custom one.
Here are some code snippets.  Thanks in advance for any help!

public class CustomValidator implements Serializable 
{
	public static boolean validateRange(Object bean, ValidatorAction va,

					Field field, ActionErrors errors,
HttpServletRequest request)
	{
		return false;
	}
}


validator-rules.xml:

   	  <!-- Custom Validators -->
      
      <validator name="validRange"
            classname="com.moog.us.app.ans.validation.CustomValidator"
               method="validateRange"
         methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionErrors,
                       javax.servlet.http.HttpServletRequest,
                       javax.servlet.ServletContext"
                  msg="errors.invalid.range">
      </validator>


And parts of my validation.xml:

    <global>

    </global>

		<form name="/AddAssignment">
		   	<field	property="startRange"
		   			depends="required">
		   			<arg0 key="app.label.startRange"/>
		   	</field>
	   		<field	property="endRange"
		   			depends="validRange">
		   	</field>
		</form>




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org