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

struts & using js to change label text to red

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm looking for a nice way to change an input field's text label to red when there is an ActionMessage/ActionError generated by Validator. I'm handling the error message where global messages are displayed and I want to take the property names from the ActionMessage and change the label text to red based on the property name. I'm thinking fetching the labels' for attr (property) and get from the ActionMessage map. If it exists,then change the color.

Or there may be a slicker way of doing it. I'm open to suggestions.

Thanks
 
Jeff Horan
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem with this approach or even just passing in a String[] of the properties that are in error is knowing how to get that info in to the request object. Does Validator put an object in the request ?
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this would work:



Note: use onlode was used above instead of onload to get around the JavaRanch filter.
[ October 25, 2006: Message edited by: Merrill Higginson ]
 
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
say you have



how will you recognise "Your name" in order to change it's color? i dont think that's easy...

in my app, i'm not changing the field's description color but render a bold red error message right below the field.



there is a struts application property which leads and one that trails an error message. i'm using this fields to render




arround the error text. The style itself takes care of color, font style and of the required line break.

pretty satisfied with this solution :-)

jan
[ October 26, 2006: Message edited by: Jan Groth ]
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For an example on Highlighting Error Fields you can refer here.

Struts Highlighting Error Fields

regards
Struts Developer

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The link that Nyanas had mentioned does not seem to be working. Can someone provide me a solution to highlight the Label for example "Your Name" (refer previous messages by Jeff) to red on error. I am using bean:message to display the label on the page. Thanks
 
Always! Wait. Never. Shut up. Look at this tiny ad.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic