Win a copy of AWS Security this week in the Cloud/Virtualization forum!
  • 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Validate errors are not being diplayed. Why?

Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im not sure what im doing wrong, but the errors (ie mandatory fields are left blank) are not being diplayed once the form is being validated.
Thank you for your time.
<action input="/HtmlFile.jsp" name="FileForm" path="/HtmlFile"
scope="session" type="ch12.HtmlFileAction" validate="true">
<forward name="default" path="/HtmlFile.jsp"/>
<body >
<html:form action="" enctype="multipart/form-data">

Item Type
<html:select name="HtmlFileForm" property="itemType">
<html ptions collection="itemlists" property="id" labelProperty="description"/>
Item ID
<html:text property="name"/>
Thumbnail Image
<html:file property="file"/>
<html:text property="price"/>
<br />
<html:submit />
public class FileForm extends ActionForm{
private String submit;

public ActionErrors validate( ActionMapping mapping, HttpServletRequest request )
ActionErrors errors = new ActionErrors();
if(getFile() ==null)
errors.add("file",new ActionError ("error.file.required"));
if ( getPrice() == null || getPrice().length() < 1 )
errors.add("price",new ActionError("error.price.required"));

return errors;
Ranch Hand
Posts: 374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) Check that you have your message resources file (i.e. specified in your struts config.
2) Check that the file is there, where you expect it to be.
3) Check that the specified message key is present in the file.
1 I can't help with.
2 Try adding the following to your file and restarting your app, then rerunning your test that should display errors...
# html:errors tag configuration ------------------------------------------
If your file is loaded properly, your messages will now be in a bulleted list. If you see
Or something similar, your problem is likely with #3.
Let me tell you a story about a man named Jed. He made this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic