Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

DynaValidatorForm problem

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm trying to implement the Commons validator framework on my project but I am having a few problems. I am using the DynaValidatorForm to validate my forms. At the moment I am just trying to make it work on a logon form. Here are the files I'm using.
The error that I am getting at the moment is this.
2003-11-27 15:42:48,837 [ERROR] org.apache.commons.validator.Validator: reflection: org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest)
java.lang.NoSuchMethodException: org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest)
java.lang.reflect.Method java.lang.Class.getMethod0(java.lang.String, java.lang.Class[], int)
native code
java.lang.reflect.Method java.lang.Class.getMethod(java.lang.String, java.lang.Class[])
Class.java:888
boolean org.apache.commons.validator.Validator.validateFieldForRule(org.apache.commons.validator.Field, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.ValidatorResults, java.util.Map, int)
Validator.java:401
void org.apache.commons.validator.Validator.validateField(org.apache.commons.validator.Field, org.apache.commons.validator.ValidatorResults)
Validator.java:544
org.apache.commons.validator.ValidatorResults org.apache.commons.validator.Validator.validate()
Validator.java:582
org.apache.struts.action.ActionErrors org.apache.struts.validator.DynaValidatorForm.validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
DynaValidatorForm.java:151
boolean org.apache.struts.action.RequestProcessor.processValidate(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.struts.action.ActionForm, org.apache.struts.action.ActionMapping)
RequestProcessor.java:942
void org.apache.struts.action.RequestProcessor.process(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
RequestProcessor.java:255
void org.apache.struts.action.ActionServlet.process(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
ActionServlet.java:1482
void org.apache.struts.action.ActionServlet.doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
ActionServlet.java:525
void javax.servlet.http.HttpServlet.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
HttpServlet.java:760
void javax.servlet.http.HttpServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
HttpServlet.java:853
void com.evermind.server.http.ServletRequestDispatcher.invoke(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
ServletRequestDispatcher.java:721
void com.evermind.server.http.ServletRequestDispatcher.forwardInternal(javax.servlet.ServletRequest, javax.servlet.http.HttpServletResponse)
ServletRequestDispatcher.java:306
boolean com.evermind.server.http.HttpRequestHandler.processRequest(com.evermind.server.ApplicationServerThread, com.evermind.server.http.EvermindHttpServletRequest, com.evermind.server.http.EvermindHttpServletResponse, java.io.InputStream, java.io.OutputStream, boolean)
HttpRequestHandler.java:767
void com.evermind.server.http.HttpRequestHandler.run(java.lang.Thread)
HttpRequestHandler.java:259
void com.evermind.server.http.HttpRequestHandler.run()
HttpRequestHandler.java:106
void EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run()
PooledExecutor.java:803
void java.lang.Thread.run()
Thread.java:484
-------------------------------------------------------
struts-config.xml
<form-bean name="TestLogonActionForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="username" type="java.lang.String"/>
<form-property name="password" type="java.lang.String"/>
</form-bean>
<action path="/testLogonForm" type="gov.ons.classifications.controller.action.TestLogonAction" name="TestLogonActionForm" validate="true" scope="request" input="/TestLogonForm.jsp">
<forward name="success" path="/TestLogonForm.jsp" />
</action>

--------------------------------------------------
validation.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.0//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_0.dtd">
<!--
Validation Rules for the Struts Example Web Application
$Id: validation.xml,v 1.8 2003/05/25 22:51:20 dgraham Exp $
-->
<form-validation>

<!-- ========== Default Language Form Definitions ===================== -->
<formset>
<!-- logonForm validation-->
<form name="TestLogonActionForm">
<field property="username" depends="required">
<arg0 key="title.details"/>
</field>
<field property="password" depends="required">
<arg0 key="title.details"/>
</field>
</form>
</formset>
</form-validation>

----------------------------------------------
My ActionForm
package gov.ons.classifications.controller.action;
import controller.action.BaseAction;
import gov.ons.classifications.controller.form.LoginActionForm;
import org.apache.struts.validator.DynaValidatorForm;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.*;
public class TestLogonAction extends Action
{
/**
* Logger object for the instance of this class
*/
private static Log logger = LogFactory.getLog(LoginAction.class);
public TestLogonAction()
{
super();
}
/**
* actionForward implementation
*/
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws ServletException
{
logger.debug("Entering execute method of LoginAction");
DynaValidatorForm f = (DynaValidatorForm) form;
String person = (String) f.get("username");
logger.debug("Entering execute method of LoginAction ====>"+f);

return mapping.findForward("success");
}
}

Any help with this would be greatly appreciated!
Thanks!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic