Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Struts and the fly likes Form mapping based on ActionErrors etc? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Form mapping based on ActionErrors etc?" Watch "Form mapping based on ActionErrors etc?" New topic
Author

Form mapping based on ActionErrors etc?

Max Tomlinson
Ranch Hand

Joined: Jul 17, 2001
Posts: 365
Does anyone know of any struts tags or technique to automatically highlight or change font colro or focus a form tag based on the input of a ActionErrors object?
For example, if I have an text box named �foo� and my ActionError object returns an identifier �foo� I know want to highlight that field e.g. paint it red, place the cursor there etc?

Any ideas?

thanks
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You could create javascript init() method and call it from the body's onload event. In that method, put something like the following:

<logic:messagesPresent property="foo">
document.myForm.foo.style.color = 'red';
document.myForm.foo.focus();
</logic:messagesPresent>
[ August 04, 2005: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Max Tomlinson
Ranch Hand

Joined: Jul 17, 2001
Posts: 365
Perfect-

thanks, Merrill-

Max
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Form mapping based on ActionErrors etc?
 
Similar Threads
ActionErrors in validate method
Java doubt
instanceof
Highlight row on value change
validate method is not being called