You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sivakumar Santharam <am...@gmail.com> on 2005/03/03 20:28:52 UTC
problem in custom validation method
I am using struts 1.2.4 I created a new custom validation method in a
validator class. I added a new validation rule to the validator-rules.xml file
and new validation definitions to the validation.xml file. I get the following
error when the custome validation method is called. When I tried to debug by
setting a debug point in the validation method, it didn't stop. I don't have a
clue what is happening. Thanks in advance.
Siva
Error trace:
-----------
[3/3/05 14:21:48:926 EST] 7de0aacf ValidatorForm E
org.apache.struts.validator.ValidatorForm TRAS0014I: The following exception
was logged org.apache.commons.validator.ValidatorException:
gov.tva.wrkrcomp.util.Validator.validateInt(java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages,
javax.servlet.http.HttpServletRequest)
at org.apache.commons.validator.ValidatorAction.loadValidationMethod
(ValidatorAction.java:627)
at org.apache.commons.validator.ValidatorAction.executeValidationMethod
(ValidatorAction.java:557)
at org.apache.commons.validator.Field.validateForRule(Field.java:811)
at org.apache.commons.validator.Field.validate(Field.java:890)
at org.apache.commons.validator.Form.validate(Form.java:174)
at org.apache.commons.validator.Validator.validate(Validator.java:367)
at org.apache.struts.validator.ValidatorForm.validate
(ValidatorForm.java:112)
at org.apache.struts.action.RequestProcessor.processValidate
(RequestProcessor.java:921)
at org.apache.struts.action.RequestProcessor.process
(RequestProcessor.java:206)
at org.apache.struts.action.ActionServlet.process
(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doPost
(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService
(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service
(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service
(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service
(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service
(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch
(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch
(ServletInstanceReference.java:40)
at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch
(WebAppRequestDispatcher.java:983)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch
(WebAppRequestDispatcher.java:564)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward
(WebAppRequestDispatcher.java:200)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward
(WebAppInvoker.java:119)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook
(WebAppInvoker.java:276)
at
com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation
(CachedInvocation.java:71)
at
com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke
(CacheableInvocationContext.java:116)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI
(ServletRequestProcessor.java:186)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service
(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest
(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest
(HttpConnection.java:618)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)
.
org.apache.commons.validator.ValidatorException:
gov.tva.wrkrcomp.util.Validator.validateInt(java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages,
javax.servlet.http.HttpServletRequest)
at org.apache.commons.validator.ValidatorAction.loadValidationMethod
(ValidatorAction.java:627)
at org.apache.commons.validator.ValidatorAction.executeValidationMethod
(ValidatorAction.java:557)
at org.apache.commons.validator.Field.validateForRule(Field.java:811)
at org.apache.commons.validator.Field.validate(Field.java:890)
at org.apache.commons.validator.Form.validate(Form.java:174)
at org.apache.commons.validator.Validator.validate(Validator.java:367)
at org.apache.struts.validator.ValidatorForm.validate
(ValidatorForm.java:112)
at org.apache.struts.action.RequestProcessor.processValidate
(RequestProcessor.java:921)
at org.apache.struts.action.RequestProcessor.process
(RequestProcessor.java:206)
at org.apache.struts.action.ActionServlet.process
(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doPost
(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService
(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service
(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service
(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service
(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service
(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch
(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch
(ServletInstanceReference.java:40)
at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch
(WebAppRequestDispatcher.java:983)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch
(WebAppRequestDispatcher.java:564)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward
(WebAppRequestDispatcher.java:200)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward
(WebAppInvoker.java:119)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook
(WebAppInvoker.java:276)
at
com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation
(CachedInvocation.java:71)
at
com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke
(CacheableInvocationContext.java:116)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI
(ServletRequestProcessor.java:186)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service
(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest
(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest
(HttpConnection.java:618)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: problem in custom validation method
Posted by Sivakumar Santharam <am...@gmail.com>.
Niall Pemberton <niall.pemberton <at> blueyonder.co.uk> writes:
>
> Probably the best place to look is the "upgrade notes" page in the wiki.
> Unfortunately this issue wasn't on it, so I've just added a note about it.
>
> http://wiki.apache.org/struts/StrutsUpgradeNotes11to124
>
> Niall
>
> ----- Original Message -----
> From: "Erik Weber" <erikweber <at> mindspring.com>
> Sent: Thursday, March 03, 2005 11:23 PM
>
> > Geez, thanks Niall. I've been posting custom validation examples that
> > wouldn't work with 1.2 and didn't realize it. Please let me know if
> > there are any other significant validator plugin changes from 1.1 to 1.2.
> >
> > Erik
>
Niall
I replaced ActionErrors with ActionMessages in the method signature and
everything worked fine. Thanks for your help.
Siva
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: problem in custom validation method
Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
Probably the best place to look is the "upgrade notes" page in the wiki.
Unfortunately this issue wasn't on it, so I've just added a note about it.
http://wiki.apache.org/struts/StrutsUpgradeNotes11to124
Niall
----- Original Message -----
From: "Erik Weber" <er...@mindspring.com>
Sent: Thursday, March 03, 2005 11:23 PM
> Geez, thanks Niall. I've been posting custom validation examples that
> wouldn't work with 1.2 and didn't realize it. Please let me know if
> there are any other significant validator plugin changes from 1.1 to 1.2.
>
> Erik
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: problem in custom validation method
Posted by Erik Weber <er...@mindspring.com>.
Geez, thanks Niall. I've been posting custom validation examples that
wouldn't work with 1.2 and didn't realize it. Please let me know if
there are any other significant validator plugin changes from 1.1 to 1.2.
Erik
Niall Pemberton wrote:
>The validation method signatures in Struts 1.2 changed from ActionErrors to
>ActionMessages, but it looks like you're trying to use a Struts 1.1 format
>method with Struts 1.2.
>
>Try changing your method signature to use ActionMessages.
>
>Niall
>
>----- Original Message -----
>From: "Sivakumar Santharam" <am...@gmail.com>
>Sent: Thursday, March 03, 2005 10:45 PM
>
>
>
>
>>>>Error trace:
>>>>-----------
>>>>[3/3/05 14:21:48:926 EST] 7de0aacf ValidatorForm E
>>>>org.apache.struts.validator.ValidatorForm TRAS0014I: The following
>>>>exception was logged org.apache.commons.validator.ValidatorException:
>>>>gov.tva.wrkrcomp.util.Validator.validateInt(java.lang.Object,
>>>>org.apache.commons.validator.ValidatorAction,
>>>>org.apache.commons.validator.Field,
>>>>org.apache.struts.action.ActionMessages,
>>>>javax.servlet.http.HttpServletRequest)
>>>>at org.apache.commons.validator.ValidatorAction.loadValidationMethod
>>>>(ValidatorAction.java:627)
>>>>
>>>>
>
>
>
>>Bill,
>>Thanks for your reply. I was trying to write a custome validation method
>>
>>
>to
>
>
>>see whether it is working or not. I checked the method definition
>>(validateInt) and the declaration (int) in the validator-rules.xml and it
>>looks same.
>>Here is the sample code. I removed the generic validation methods to make
>>
>>
>it
>
>
>>simple. Thanks Siva
>>
>>------ validator class --
>>public static boolean validateInt(Object bean,ValidatorAction action,
>>Field field,ActionErrors errors,HttpServletRequest request) {
>>String value = ValidatorUtils.getValueAsString(bean,
>>field.getProperty());
>>boolean isFieldValid = false;
>>try {
>> Integer.parseInt(value);
>> isFieldValid = true;
>>} catch (Exception e) {
>>errors.add(field.getKey(), Resources.getActionError
>>(request, action, field));
>>isFieldValid = false;
>>}
>>return isFieldValid;
>>}
>>
>>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: problem in custom validation method
Posted by Sivakumar Santharam <am...@gmail.com>.
Niall Pemberton <niall.pemberton <at> blueyonder.co.uk> writes:
>
> The validation method signatures in Struts 1.2 changed from ActionErrors to
> ActionMessages, but it looks like you're trying to use a Struts 1.1 format
> method with Struts 1.2.
>
> Try changing your method signature to use ActionMessages.
>
> Niall
Niall,
Yes, that was the problem. I replaced ActionErrors with ActionMessages in the
method signature and it worked fine. I appreciate your help. Thank you.
Siva
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: problem in custom validation method
Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
The validation method signatures in Struts 1.2 changed from ActionErrors to
ActionMessages, but it looks like you're trying to use a Struts 1.1 format
method with Struts 1.2.
Try changing your method signature to use ActionMessages.
Niall
----- Original Message -----
From: "Sivakumar Santharam" <am...@gmail.com>
Sent: Thursday, March 03, 2005 10:45 PM
> > > Error trace:
> > > -----------
> > > [3/3/05 14:21:48:926 EST] 7de0aacf ValidatorForm E
> > > org.apache.struts.validator.ValidatorForm TRAS0014I: The following
> > > exception was logged org.apache.commons.validator.ValidatorException:
> > > gov.tva.wrkrcomp.util.Validator.validateInt(java.lang.Object,
> > > org.apache.commons.validator.ValidatorAction,
> > > org.apache.commons.validator.Field,
> > > org.apache.struts.action.ActionMessages,
> > > javax.servlet.http.HttpServletRequest)
> > > at org.apache.commons.validator.ValidatorAction.loadValidationMethod
> > > (ValidatorAction.java:627)
> Bill,
> Thanks for your reply. I was trying to write a custome validation method
to
> see whether it is working or not. I checked the method definition
> (validateInt) and the declaration (int) in the validator-rules.xml and it
> looks same.
> Here is the sample code. I removed the generic validation methods to make
it
> simple. Thanks Siva
>
> ------ validator class --
> public static boolean validateInt(Object bean,ValidatorAction action,
> Field field,ActionErrors errors,HttpServletRequest request) {
> String value = ValidatorUtils.getValueAsString(bean,
> field.getProperty());
> boolean isFieldValid = false;
> try {
> Integer.parseInt(value);
> isFieldValid = true;
> } catch (Exception e) {
> errors.add(field.getKey(), Resources.getActionError
> (request, action, field));
> isFieldValid = false;
> }
> return isFieldValid;
> }
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: problem in custom validation method
Posted by Sivakumar Santharam <am...@gmail.com>.
Bill Siggelkow <billsigg <at> bellsouth.net> writes:
>
> It looks like to me that the Validator is not finding your method
> definition. Recheck the declaration in the validator-rules.xml file.
> The signature and class name there must match your actual class and
> method exactly.
>
> On 2005-03-03 14:28:52 -0500, Sivakumar Santharam <ambalam <at> gmail.com>
said:
>
> > I am using struts 1.2.4 I created a new custom validation method in a
> > validator class. I added a new validation rule to the
> > validator-rules.xml file and new validation definitions to the
> > validation.xml file. I get the following error when the custome
> > validation method is called. When I tried to debug by setting a debug
> > point in the validation method, it didn't stop. I don't have a clue
> > what is happening. Thanks in advance. Siva
> >
> > Error trace:
> > -----------
> > [3/3/05 14:21:48:926 EST] 7de0aacf ValidatorForm E
> > org.apache.struts.validator.ValidatorForm TRAS0014I: The following
> > exception was logged org.apache.commons.validator.ValidatorException:
> > gov.tva.wrkrcomp.util.Validator.validateInt(java.lang.Object,
> > org.apache.commons.validator.ValidatorAction,
> > org.apache.commons.validator.Field,
> > org.apache.struts.action.ActionMessages,
> > javax.servlet.http.HttpServletRequest)
> > at org.apache.commons.validator.ValidatorAction.loadValidationMethod
> > (ValidatorAction.java:627)
> > at org.apache.commons.validator.ValidatorAction.executeValidationMethod
> > (ValidatorAction.java:557)
> > at org.apache.commons.validator.Field.validateForRule(Field.java:811)
> > at org.apache.commons.validator.Field.validate(Field.java:890)
> > at org.apache.commons.validator.Form.validate(Form.java:174)
> > at org.apache.commons.validator.Validator.validate(Validator.java:367)
> > at org.apache.struts.validator.ValidatorForm.validate
> > (ValidatorForm.java:112)
> > at org.apache.struts.action.RequestProcessor.processValidate
> > (RequestProcessor.java:921)
> > at org.apache.struts.action.RequestProcessor.process
> > (RequestProcessor.java:206)
> > at org.apache.struts.action.ActionServlet.process
> > (ActionServlet.java:1164)
> > at org.apache.struts.action.ActionServlet.doPost
> > (ActionServlet.java:415)
> > at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
> > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> > at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService
> > (StrictServletInstance.java:110)
> > at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service
> > (StrictLifecycleServlet.java:174)
> > at com.ibm.ws.webcontainer.servlet.IdleServletState.service
> > (StrictLifecycleServlet.java:313)
> > at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service
> > (StrictLifecycleServlet.java:116)
> > at com.ibm.ws.webcontainer.servlet.ServletInstance.service
> > (ServletInstance.java:283)
> > at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch
> > (ValidServletReferenceState.java:42)
> > at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch
> > (ServletInstanceReference.java:40)
> > at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch
> > (WebAppRequestDispatcher.java:983)
> > at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch
> > (WebAppRequestDispatcher.java:564)
> > at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward
> > (WebAppRequestDispatcher.java:200)
> > at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward
> > (WebAppInvoker.java:119)
> > at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook
> > (WebAppInvoker.java:276)
> > at
com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation
> > (CachedInvocation.java:71)
> > at
com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke
> > (CacheableInvocationContext.java:116)
> > at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI
> > (ServletRequestProcessor.java:186)
> > at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service
> > (OSEListener.java:334)
> > at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest
> > (HttpConnection.java:56)
> > at com.ibm.ws.http.HttpConnection.readAndHandleRequest
> > (HttpConnection.java:618)
> > at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
> > at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)
> > .
> >
> > org.apache.commons.validator.ValidatorException:
> > gov.tva.wrkrcomp.util.Validator.validateInt(java.lang.Object,
> > org.apache.commons.validator.ValidatorAction,
> > org.apache.commons.validator.Field,
> > org.apache.struts.action.ActionMessages,
> > javax.servlet.http.HttpServletRequest)
> > at org.apache.commons.validator.ValidatorAction.loadValidationMethod
> > (ValidatorAction.java:627)
> > at org.apache.commons.validator.ValidatorAction.executeValidationMethod
> > (ValidatorAction.java:557)
> > at org.apache.commons.validator.Field.validateForRule(Field.java:811)
> > at org.apache.commons.validator.Field.validate(Field.java:890)
> > at org.apache.commons.validator.Form.validate(Form.java:174)
> > at org.apache.commons.validator.Validator.validate(Validator.java:367)
> > at org.apache.struts.validator.ValidatorForm.validate
> > (ValidatorForm.java:112)
> > at org.apache.struts.action.RequestProcessor.processValidate
> > (RequestProcessor.java:921)
> > at org.apache.struts.action.RequestProcessor.process
> > (RequestProcessor.java:206)
> > at org.apache.struts.action.ActionServlet.process
> > (ActionServlet.java:1164)
> > at org.apache.struts.action.ActionServlet.doPost
> > (ActionServlet.java:415)
> > at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
> > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> > at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService
> > (StrictServletInstance.java:110)
> > at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service
> > (StrictLifecycleServlet.java:174)
> > at com.ibm.ws.webcontainer.servlet.IdleServletState.service
> > (StrictLifecycleServlet.java:313)
> > at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service
> > (StrictLifecycleServlet.java:116)
> > at com.ibm.ws.webcontainer.servlet.ServletInstance.service
> > (ServletInstance.java:283)
> > at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch
> > (ValidServletReferenceState.java:42)
> > at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch
> > (ServletInstanceReference.java:40)
> > at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch
> > (WebAppRequestDispatcher.java:983)
> > at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch
> > (WebAppRequestDispatcher.java:564)
> > at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward
> > (WebAppRequestDispatcher.java:200)
> > at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward
> > (WebAppInvoker.java:119)
> > at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook
> > (WebAppInvoker.java:276)
> > at
com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation
> > (CachedInvocation.java:71)
> > at
com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke
> > (CacheableInvocationContext.java:116)
> > at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI
> > (ServletRequestProcessor.java:186)
> > at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service
> > (OSEListener.java:334)
> > at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest
> > (HttpConnection.java:56)
> > at com.ibm.ws.http.HttpConnection.readAndHandleRequest
> > (HttpConnection.java:618)
> > at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
> > at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)
>
Bill,
Thanks for your reply. I was trying to write a custome validation method to
see whether it is working or not. I checked the method definition
(validateInt) and the declaration (int) in the validator-rules.xml and it
looks same.
Here is the sample code. I removed the generic validation methods to make it
simple. Thanks Siva
------ validator class --
public static boolean validateInt(Object bean,ValidatorAction action,
Field field,ActionErrors errors,HttpServletRequest request) {
String value = ValidatorUtils.getValueAsString(bean,
field.getProperty());
boolean isFieldValid = false;
try {
Integer.parseInt(value);
isFieldValid = true;
} catch (Exception e) {
errors.add(field.getKey(), Resources.getActionError
(request, action, field));
isFieldValid = false;
}
return isFieldValid;
}
---------- validation-rules.xml ---------
<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules
Configuration 1.1.3//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
<form-validation>
<global>
<validator name="int"
classname="gov.tva.wrkrcomp.util.Validator"
method="validateInt"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.integer"/>
</global>
</form-validation>
---- validation.xml -----------
<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules
Configuration 1.1.3//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
<form-validation>
<formset>
<form name="/addDependent">
<field property="phoneAreaCd" depends="required,int,minlength">
<arg0 key="dependent.phone.areacd" />
<arg1 name="minlength" key="${var:minlength}"
resource="false" />
<var>
<var-name>minlength</var-name>
<var-value>3</var-value>
</var>
</field>
</form>
</formset>
</form-validation>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: problem in custom validation method
Posted by Bill Siggelkow <bi...@bellsouth.net>.
It looks like to me that the Validator is not finding your method
definition. Recheck the declaration in the validator-rules.xml file.
The signature and class name there must match your actual class and
method exactly.
On 2005-03-03 14:28:52 -0500, Sivakumar Santharam <am...@gmail.com> said:
> I am using struts 1.2.4 I created a new custom validation method in a
> validator class. I added a new validation rule to the
> validator-rules.xml file and new validation definitions to the
> validation.xml file. I get the following error when the custome
> validation method is called. When I tried to debug by setting a debug
> point in the validation method, it didn't stop. I don't have a clue
> what is happening. Thanks in advance. Siva
>
> Error trace:
> -----------
> [3/3/05 14:21:48:926 EST] 7de0aacf ValidatorForm E
> org.apache.struts.validator.ValidatorForm TRAS0014I: The following
> exception was logged org.apache.commons.validator.ValidatorException:
> gov.tva.wrkrcomp.util.Validator.validateInt(java.lang.Object,
> org.apache.commons.validator.ValidatorAction,
> org.apache.commons.validator.Field,
> org.apache.struts.action.ActionMessages,
> javax.servlet.http.HttpServletRequest)
> at org.apache.commons.validator.ValidatorAction.loadValidationMethod
> (ValidatorAction.java:627)
> at org.apache.commons.validator.ValidatorAction.executeValidationMethod
> (ValidatorAction.java:557)
> at org.apache.commons.validator.Field.validateForRule(Field.java:811)
> at org.apache.commons.validator.Field.validate(Field.java:890)
> at org.apache.commons.validator.Form.validate(Form.java:174)
> at org.apache.commons.validator.Validator.validate(Validator.java:367)
> at org.apache.struts.validator.ValidatorForm.validate
> (ValidatorForm.java:112)
> at org.apache.struts.action.RequestProcessor.processValidate
> (RequestProcessor.java:921)
> at org.apache.struts.action.RequestProcessor.process
> (RequestProcessor.java:206)
> at org.apache.struts.action.ActionServlet.process
> (ActionServlet.java:1164)
> at org.apache.struts.action.ActionServlet.doPost
> (ActionServlet.java:415)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService
> (StrictServletInstance.java:110)
> at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service
> (StrictLifecycleServlet.java:174)
> at com.ibm.ws.webcontainer.servlet.IdleServletState.service
> (StrictLifecycleServlet.java:313)
> at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service
> (StrictLifecycleServlet.java:116)
> at com.ibm.ws.webcontainer.servlet.ServletInstance.service
> (ServletInstance.java:283)
> at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch
> (ValidServletReferenceState.java:42)
> at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch
> (ServletInstanceReference.java:40)
> at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch
> (WebAppRequestDispatcher.java:983)
> at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch
> (WebAppRequestDispatcher.java:564)
> at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward
> (WebAppRequestDispatcher.java:200)
> at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward
> (WebAppInvoker.java:119)
> at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook
> (WebAppInvoker.java:276)
> at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation
> (CachedInvocation.java:71)
> at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke
> (CacheableInvocationContext.java:116)
> at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI
> (ServletRequestProcessor.java:186)
> at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service
> (OSEListener.java:334)
> at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest
> (HttpConnection.java:56)
> at com.ibm.ws.http.HttpConnection.readAndHandleRequest
> (HttpConnection.java:618)
> at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
> at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)
> .
>
> org.apache.commons.validator.ValidatorException:
> gov.tva.wrkrcomp.util.Validator.validateInt(java.lang.Object,
> org.apache.commons.validator.ValidatorAction,
> org.apache.commons.validator.Field,
> org.apache.struts.action.ActionMessages,
> javax.servlet.http.HttpServletRequest)
> at org.apache.commons.validator.ValidatorAction.loadValidationMethod
> (ValidatorAction.java:627)
> at org.apache.commons.validator.ValidatorAction.executeValidationMethod
> (ValidatorAction.java:557)
> at org.apache.commons.validator.Field.validateForRule(Field.java:811)
> at org.apache.commons.validator.Field.validate(Field.java:890)
> at org.apache.commons.validator.Form.validate(Form.java:174)
> at org.apache.commons.validator.Validator.validate(Validator.java:367)
> at org.apache.struts.validator.ValidatorForm.validate
> (ValidatorForm.java:112)
> at org.apache.struts.action.RequestProcessor.processValidate
> (RequestProcessor.java:921)
> at org.apache.struts.action.RequestProcessor.process
> (RequestProcessor.java:206)
> at org.apache.struts.action.ActionServlet.process
> (ActionServlet.java:1164)
> at org.apache.struts.action.ActionServlet.doPost
> (ActionServlet.java:415)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService
> (StrictServletInstance.java:110)
> at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service
> (StrictLifecycleServlet.java:174)
> at com.ibm.ws.webcontainer.servlet.IdleServletState.service
> (StrictLifecycleServlet.java:313)
> at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service
> (StrictLifecycleServlet.java:116)
> at com.ibm.ws.webcontainer.servlet.ServletInstance.service
> (ServletInstance.java:283)
> at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch
> (ValidServletReferenceState.java:42)
> at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch
> (ServletInstanceReference.java:40)
> at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch
> (WebAppRequestDispatcher.java:983)
> at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch
> (WebAppRequestDispatcher.java:564)
> at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward
> (WebAppRequestDispatcher.java:200)
> at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward
> (WebAppInvoker.java:119)
> at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook
> (WebAppInvoker.java:276)
> at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation
> (CachedInvocation.java:71)
> at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke
> (CacheableInvocationContext.java:116)
> at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI
> (ServletRequestProcessor.java:186)
> at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service
> (OSEListener.java:334)
> at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest
> (HttpConnection.java:56)
> at com.ibm.ws.http.HttpConnection.readAndHandleRequest
> (HttpConnection.java:618)
> at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
> at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org