File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts error, focus the error field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts error, focus the error field" Watch "Struts error, focus the error field" New topic

Struts error, focus the error field

Nilesh Naik

Joined: Jul 18, 2006
Posts: 13
I have a struts jsp and ActionForm for that jsp. The form validation is done in the action form.If there are any errors, those are displayed on the jsp.
I want to get the focus on the first error field on the jsp.

Can anyone let me know how to do that?

Jan Groth
Ranch Hand

Joined: Feb 03, 2004
Posts: 456
i dont know of any mechanism you could use...

guess you will need a scriptlet / js which parses the error map in the request / session and focuses the right field on the page if a appropriate error is found.

no rocket science, but you'll probably need a few hours to test and implement.

also note that "the first field" is something you can usually not decide automatically.


happy coding,
[ January 19, 2007: Message edited by: Jan Groth ]
I agree. Here's the link:
subject: Struts error, focus the error field
It's not a secret anymore!