Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming 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 ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

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"/>
</action>
<html:html>
<body >
<html:errors/>
<html:form action="HtmlFile.do" enctype="multipart/form-data">

Item Type
<html:select name="HtmlFileForm" property="itemType">
<html ptions collection="itemlists" property="id" labelProperty="description"/>
</html:select>
<br/>
Item ID
<br/>
<html:text property="name"/>
<br/>
Thumbnail Image
<br/>
<html:file property="file"/>
<br/>
Price
<br/>
<html:text property="price"/>
<br />
<html:submit />
</html:form>
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. ApplicationResources.properties) 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 ApplicationResources.properties file and restarting your app, then rerunning your test that should display errors...
# html:errors tag configuration ------------------------------------------
errors.header=<ul>
errors.prefix=<li>
errors.suffix=</li>
errors.footer=</ul>
If your file is loaded properly, your messages will now be in a bulleted list. If you see
(bullet)
(bullet)
Or something similar, your problem is likely with #3.
 
The only cure for that is hours of television radiation. And this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!