• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to error msg next to an html comonent ?

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello im new to struts and i would like to now how to get qoute "
The default code for queuing an error message is:
errors.add(
ActionErrors.GLOBAL_ERROR,
new ActionError("error.username.required")
);
To specify that this message is for the "username" property, we would code this instead:
errors.add(
"username", new ActionError("error.username.required"));
If we specify a property, we can use the <html:errors/> tag (or any of the alternatives) like this:
<P>Username: <html:text property="username"/></P>
<P>Password: <html assword property="password"/></P>
The "username" errors print next to the username field, and any "password" errors print next to the password field. "
taken from http://husted.com/struts/tips/017.html
but this dosent work ? it dosent show the error msg. if i get the msg with the <html:error property="xx"> then it works but i dont want to do that !

please help a struts beginner

//thanks rille
 
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try this,
Make two changes
instead of
errors.add(
ActionErrors.GLOBAL_ERROR,
new ActionError("error.username.required")
);
use
errors.add(
"UsernameRequired",
new ActionError("error.username.required")
);
instead of
<P>Username: <html:text property="username"/></P>
use
<P>Username: <html:text property="username"/><html:error property="UsernameRequired"/></P>
this should work
 
reply
    Bookmark Topic Watch Topic
  • New Topic