You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by bachan s <ba...@yahoo.com> on 2002/10/22 22:40:19 UTC

Error Higlighting capability of Struts Tags and JSTL Usage

Hi,

Does the input tags in struts have any inbuild error highlighting capability .

What I mean is if the validate / any other method sets an error message with the key as the field name of a field , will the tag look into the ActionErrors object for each of the input fields and check whether the key is contained in the error object and do the following .

1. Give focus to the first error field even if the error there is a field given for the focus attribute in the form.

2. Give a different style background color/ text color to all the error filed.

Also is it advisable to use struts tags /JSTL tags for tags like logic ,bean etc ????

Thanks !

Bachan



---------------------------------
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site

Re: Error Higlighting capability of Struts Tags and JSTL Usage

Posted by "David M. Karr" <dm...@earthlink.net>.
>>>>> "bachan" == bachan s <bachan> writes:

    bachan> Hi,

    bachan> Does the input tags in struts have any inbuild error highlighting capability .

    bachan> What I mean is if the validate / any other method sets an error message with the key as the field name of a field , will the tag look into the ActionErrors object for each of the input fields and check whether the key is contained in the error object and do the following .

    bachan> 1. Give focus to the first error field even if the error there is a field given for the focus attribute in the form.
    bachan> 2. Give a different style background color/ text color to all the error filed.

Struts will not do any of this automatically.  You'll have to design this
behavior into your application.

Much of this logic will be in your Action class.  If you detect an error, you
can create an ActionError class, but you can also do creative things like:

1. Using a hashmap in your form bean whose keys are the property names and
whose values are CSS style classes, set the value associated with the property
in error to the style that makes it display in red, or highlighted in some way.

2. Set a property in your form bean that specifies which field is supposed to
get the focus.  Have a javascript block in your JSP that automatically sets the
focus to that field.  Have your Action class determine which field that will
be, depending on which field is in error (if any).

    bachan> Also is it advisable to use struts tags /JSTL tags for tags like logic ,bean etc ????

I'm not exactly certain what you mean by this.  There's nothing to prevent you
from using the normal Struts tag library along with the JSTL.  Some of the JSTL
tags provide all of the functionality some of the Struts tags do, so you could
concievably use certain JSTL tags in place of certain Struts tags.

In addition, in the nightly build, there is a new package called "Struts-EL",
which provides a tag library all of whose tags are subclasses of the Struts
tags, but which evaluates attribute values using the JSTL EL engine, instead of
using runtime expression values (scriptlets).  Using this can make some things
less painful, for instance, building a javascript event handler from
concatenated pieces.  This is real ugly in a scriptlet expression (escaped
quotes, etc.), but is nice and clean in the JSTL EL syntax.

-- 
===================================================================
David M. Karr          ; Java/J2EE/XML/Unix/C++
dmkarr@earthlink.net


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>