File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

Struts error, focus the error field

Nilesh Naik
Greenhorn

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?

Regards,
Nilesh.
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,
jan
[ January 19, 2007: Message edited by: Jan Groth ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts error, focus the error field