Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

validate method doubt

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all
i am a beginner and have never worked on the framework before . while going through the book "beginning apache struts: novice to professional" i encountered the following section on formbean's validate method


public ActionErrors validate(
ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if (firstName==null
|| firstName.trim().equals(“”)){
errors.add(“firstName”,
new ActionError(
“userRegistration.firstName.problem”));
}
...
return errors;
}

Notice that when you construct an ActionError object, you must pass it a key into the resource bundle (“userRegistration.firstName”). Thus, we need to add a value to this key in the Resource bundle.
Please open the file C:\strutsTutorial\WEB-INF\src\java\resources\application.properties. Add a key value pair as follows:

userRegistration.firstName.problem=The first name was blank

i am using myeclipse 6 and hence the directory sturcture is different so where shall i find the resource bundle? and in which file should i make the key value pair entry
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

dipayan chatterjee wrote:

i am using myeclipse 6 and hence the directory sturcture is different


Not really, the directory structure is there, just your IDE using some "meaningful" names to categorized resources, like I'm using Eclipse Europa, then "WebContenet" haves JSP,HTML, etc and "src" directory contains .java files with .properties files.

dipayan chatterjee wrote:
so where shall i find the resource bundle?


If you have one, then it MUST resides on classpath, no matter in which package.

dipayan chatterjee wrote:
and in which file should i make the key value pair entry


offcourse in .properties file which you mapped in struts-config.xml file <message-resources tag. Look here for details.
>
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic