• Post Reply Bookmark Topic Watch Topic
  • New Topic

DynaValidatorForm Error  RSS feed

 
Ashish Tahasildar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I am getting an error when I tried to validate the JSP input using validator
I am using <html:javascript tag for client side validation. It show me the javascript error but when I try to submit the form it give me following error:

20:55:40,921 ERROR [DynaValidatorForm] 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)
org.apache.commons.validator.ValidatorException: org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object, org.apache.commons.validator.Validat
orAction, 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:827) at org.apache.commons.validator.Field.validate(Field.java:906)
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.DynaValidatorForm.validate(DynaValidatorForm.java:110)
at org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:927)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:204)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)

---------------------------------------
Below is my jsp file
//logonPage.jsp
<%@ page pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>

<html:html locale="true">
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>

<BODY>
<html:form action="/logon" focus="username"
onsubmit="return validateLogonForm(this);">
<html:javascript formName="logonForm"/>
<table border="0" width="100%">
<tr>
<th align="right">
<bean:message key="company.userid"/>:
</th>
<td align="left">
<html:text property="username" size="16"
maxlength="18"/>
</td>
</tr>
<tr>
<th align="right">
<bean:message key="company.password"/>:
</th>
<td align="left">
<html:text property="password" size="16"
maxlength="18"/>
</td>
</tr>
<tr>
<td>
<html:submit>Submit</html:submit>
</td>
</tr>
</table>
</html:form>
</BODY>
</html:html>


//validation.xml
<form name="logonForm">
<field property="username"
depends="required">
</field>
<field property="password"
depends="required">
</field>



</form>

--
//validator-rule.xml
default is used

//strut-config
<form-beans>
<form-bean name="logonForm"
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="username" type="java.lang.String"></form-property>
<form-property name="password" type="java.lang.String"></form-property>
</form-bean>
<action-mapping>
<action path="/logon"
type="terra.web.company.LogonAction"
name="logonForm"
scope="request"
validate="true">
<forward name="default" path="/Registration//home.jsp" />

</action>
</action-mapping>
----

///LogonAction.java
public class LogonAction extends Action {

public ActionForward execute(ActionMapping arg0, ActionForm arg1,
ServletRequest arg2, ServletResponse arg3) throws Exception {
// TODO Auto-generated method stub
System.out.println("I am in Aciton");
return arg0.findForward("default");
}
}


Please Look into the problem and let me know
Thanks in anticipation

Regards,
Ashish Tahasildar
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there more to your stack trace? I don't see what exception is being thrown.

- Brent
 
Ashish Tahasildar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
The exception thrown is org.apache.commons.validator.ValidatorException:

Regards,
Ashish Tahasildar
 
Joan Horta Tosas
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems it encounters a validation error (validation on the server side) but you don't give an input parameter, so it doesn't know where to return the error to.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!