• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

html:errors

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to do a form validation.when i use <html:errors/> in my form i am getting the exception as java.lang.ClassCastException
org.apache.struts.taglib.html.ErrorsTag.doStartTag(ErrorsTag.java:224)
messageresorces is as follows
errors.header=<h3><font color="red">Validation Error</font></h3>You must correct the following error(s) before proceeding:<ul>
errors.footer=</ul><hr>
errors.prefix=<li>
errors.suffix=</li>

########################################
# Exercise01 index page strings
########################################
page.title=Form Validation
########################################
# Form validation strings
########################################
formpage.title=Please enter your details
prompt.customer.name=Name
prompt.customer.address=Address
prompt.customer.emailAddress=EmailAddress
button.save=Save
button.cancel=Cancel

error.cust.name.empty=First Name is Required
error.cust.address.empty=Address Required
error.cust.emailAdress.empty=Email Address Required
my form bean contains
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
{
ActionErrors errors = new ActionErrors();

// name cannot be empty
if (name == null || name.trim().equals(""))
{
errors.add("name", new ActionError("error.cust.name.empty"));
}

// Address cannot be empty
if (address == null || address.trim().equals(""))
{
errors.add("address", new ActionError("error.cust.address.empty"));
}

return errors;
}
Please help me correct the error
 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it seems to be correct, can you please paste your code where you are using <html:errors/>, i mean your JSP code.
 
Sree Kumari
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the jsp


<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>

<html:html locale="true">

<head>

<title><bean:message key="page.title"/></title>

<html:base/>

</head>

<body bgcolor="white">
<html:errors/>
<html:form action="/Address">


<table>
<tr>

<td align="center" colspan="2">
<font size="4"><bean:message key="formpage.title"/></font>
</tr>
<tr>
<td alig

n="right">
<bean:message key="prompt.customer.name"/>:
</td>
<td align="left">

<html:text property="name" size="30" maxlength="30"/>
</td>
</tr>
<tr>
<td align="right">
<bean:message key="prompt.customer.address"/>:
</td>
<td align="left">

<html:text property="address" size="30" maxlength="30"/>
</td>
</tr>

<tr>
<td align="right">
<bean:message key="prompt.customer.emailAddress"/>:
</td>
<td align="left">

<html:text property="emailAddress" size="30" maxlength="30"/>
</td>
</tr>
<tr>
<td align="right">
<html:submit><bean:message key="button.save"/></html:submit>
</td>
<td align="left">
<html:cancel><bean:message key="button.cancel"/></html:cancel>
</td>
</tr>
</table>
</html:form>
</body>
</html:html>
 
Sree Kumari
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i fixed the problem by changing the version from 1.1 to 1.2.8
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic