Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Probelom in Manual Validation method

 
vasu devan
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Friends,

I am new to Struts, and using Struts 1.1
Here i encounter probelom while using Validate method in Form,following are the Details

1.ValidationAction -> Action class
2.ValidationForm ->Form class

Following are the Syntex that is used in ValidationAction class

public ActionErrors validate(ActionMapping mapping,HttpServletRequest request)
{
ActionErrors errors= new ActionErrors();

if(isMissing(getName()))
errors.add("name",new ActionMessage("name.required"));

if(isMissing(getPlace()))
errors.add("place",new ActionMessage("place.required"));

return(errors);

}

in struts-config.xml ths configuration lookes like this

<form-bean name="ValidationForm"
type="manualvalidation.ValidationForm" />

.
.
<actionpath="/Validation"
type="manualvalidation.ValidationAction"
name="ValidationForm"
scope="request"
validate="true"
input="/validation/Validation.jsp">
<forward name="success" path="/validation/success.jsp" />

</action>

<message-resources parameter="MessageResources" />

When i Accessed the page and given submit,
it return the following error in browser

org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274)
org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1012)
org.apache.struts.tiles.TilesRequestProcessor.internalModuleRelativeForward(TilesRequestProcessor.java:345)
org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:980)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:255)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.lang.ClassCastException
org.apache.struts.taglib.html.ErrorsTag.doStartTag(ErrorsTag.java:215)
org.apache.jsp.validation.Validation_jsp._jspx_meth_html_errors_0(Validation_jsp.java:129)
org.apache.jsp.validation.Validation_jsp._jspx_meth_html_html_0(Validation_jsp.java:101)
org.apache.jsp.validation.Validation_jsp._jspService(Validation_jsp.java:71)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274)
org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1012)
org.apache.struts.tiles.TilesRequestProcessor.internalModuleRelativeForward(TilesRequestProcessor.java:345)
org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:980)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:255)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

i Dont know how to fix the above probelom

Guide me to resolve the probelom

Thanks in advance
Regards,
vasu
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you're using Struts 1.1, you need to populate your ActionErrors object with objects of type ActionError, not ActionMessage. The way you've done it is correct for Struts 1.2, but not for 1.1.
 
vasu devan
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Merill,

Thanks for the Reply,
its working fine after changed to ActionError

cheers
vasu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic