You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2003/06/09 23:49:26 UTC
DO NOT REPLY [Bug 20630] New: -
[PATCH] Enhanced Style Control for Form Elements that Fail Validation
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20630>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20630
[PATCH] Enhanced Style Control for Form Elements that Fail Validation
Summary: [PATCH] Enhanced Style Control for Form Elements that
Fail Validation
Product: Struts
Version: Nightly Build
Platform: All
OS/Version: All
Status: NEW
Severity: Enhancement
Priority: Other
Component: Custom Tags
AssignedTo: struts-dev@jakarta.apache.org
ReportedBy: derose_jonathan@bah.com
There are three main parts to this enhancement:
* Allow alternate style attributes to be assigned to form inputs that will be
used if an element fails validation.
* Creation of a new 'LabelTag' that will wrap a form label. The label will
apply different styles to it's body content depending on whether it's
associated form element has passed or failed validation.
* Allow logical grouping of form elements that will allow a single error to
apply to several input elements.
* Allow alternate style attributes to be assigned:
Add an 'errorKey', 'errorStyle', 'errorStyleClass', and 'errorStyleId'
attribute to each of the form inputs (checkbox, multibox, password, radio,
select, text, textarea) in the Tag Library Descriptor. Add these data fields
to the BaseHandlerTag class. It is the super-class for every html input element.
If a developer assigns an 'errorStyle', 'errorStyleClass',
and/or 'errorStyleId' for an input element and that element fails validation,
the values assigned will be applied to the 'style', 'styleClass', and 'styleId'
attributes respectively.
-- Example --
<html:text property="name" styleClass="valid" errorStyleClass="invalid" />
If the property above passed validation (or there was no validation)
the 'class' attribute will be set to 'valid'. If the property above fails
validation the 'class' attribute will be set to 'invalid'.
-- Note --
The errorKey defaults to the value used to put errors into memory
(Globals.ERROR_KEY) and will not need to be used unless the errors are
explicitly added with a different key.
* Creation of a 'LabelTag'
The LabelTag represents a text label to a form element (or group of
elements). It will apply different styles to it's body content depending on
whether its corresponding form element(s) failed validation.
-- Example --
<html:label property="name" styleClass="valid"
errorStyleClass="invalid">Name: </html:label>
...some input(s)...
* Add logical grouping of form elements:
Quite often we want to define an error on a group of elements instead of a
specific element. (E.g. a social security number is 3 text inputs, an address
may be several different inputs.) With this enhancement a validation error can
apply to either a group of elements or to the property of one specific
element. If an element belongs to a group it will check to see if the group
passed validation in addition to checking to see if its specific property
passed validation.
-- Example --
If there was a problem with any part of the SSN during validation, the error
can be created on the entire SSN group.
errors.add("ssn", new ActionError(....));
< html:label group="ssn" styleClass="valid"
errorStyleClass="invalid">SSN:</html:label>
< html:text property="ssn1" group="ssn" styleClass="valid"
errorStyleClass="invalid" />-
< html:text property="ssn2" group="ssn" styleClass="valid"
errorStyleClass="invalid" />-
< html:text property="ssn3" group="ssn" styleClass="valid"
errorStyleClass="invalid" />
Every element with 'ssn' as the group will detect the error and use the
errorStyleClass defined for it. (In this example 'invalid' makes the label bold
and red and makes the input elements have a red background.)
--------------------------------------------------------------------
I have attached the following:
combined.txt - WinCvs diff reports for all of the affected classes
LabelTag.java - The source for the new LabelTag
struts-html-tld.txt - The diff report for the struts-html.tld file
Let me know if there are any thoughts, questions, suggestions, or if it looks
like I left anything out.
Thanks,
Jonathan R. DeRose
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org