• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

In-line Validation

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone point me in the right direction for putting validation error message beside or below the appropriate validating field? I can only find examples where they just list all the errors at the top of the page, and that is just not very eye pleasing.
Thanks.
 
sandy gupta
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gregg,
You can pull the actionerrors object out of the pageContext on the jsp page and then pull use the action errors api to pull out the individual error messages. What the html:errors tag does is the same thing just that it pulls out all the action error messages but u cud pull them out one by one.
HTH
 
Chad McGowan
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<html:errors property="userId"/>
will retrieve only the action error named 'userId'. You can place this anywhere on your page.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thought I would drudge this old post of mine because I am having a problem with putting the validation in-line with the correct field on the form.
When I do <html:errors property="name" /> it also pulls the error.header property and of course that just looks horrible.
First, why does it pull that header automatically and Second, if I just remove that property from the application.properties, will it still work? Or does <html:errors/> need that all the time to function?
 
Junilu Lacar
Bartender
Posts: 7600
53
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AFAIK, the header and footer keys are optional: the tag uses them if it finds them, otherwise it just renders the error messages. Of course, if you strip out the header and footer from the resource bundle and you have pages where you do want the header and footer, those will be now be F'd up. Alternatively, you could leave the header and footer and use html:messages for your field-specific errors.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could really care less about the header and footer tags. I always like to just display messages where I want them. Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic