|
Created an attachment (id=6838)
LabelTag.java - Source Code for new Tag ***
There is another proposal on this topic in STR-1305.
Created an attachment (id=6978)
Updated LabelTag that uses resource bundles or body content for the label Created an attachment (id=6979)
Updated diff report (-u format) I have modified the LabelTag (thanks to some great ideas from listserv) to use
a label from the resource properties if a key is provided. If a key is not provided, the body content of the label tag will be used as previously described. Now you will get error handling for either of the following: <html:label property="password" key="label.property"/> -or- <html:label property="password">Password</html:label> The two attachements marked *updated* contain the current code. HTH, Jonathan R. DeRose PS. Doah! while writing this I realized I left out the release method for the updated LabelTag (reseting the key to null), I will add it tomorrow. Sorry about that. Created an attachment (id=7020)
Updated LabelTag can now be easily extended (to add formatting for required fields or other mods) This tag sounds like a very good addition to Struts. The only thing I was
wondering is, why you're using <span> markup for the label text and not <label> (http://www.w3.org/TR/html4/interact/forms.html#h-17.9): <form action="foo.do"> <p> <label class="error" for="firstNameId">First name:</label> <input id="firstNameId" name="firstName" type="text"> <br> <label style="normal" for="lastNameId">Last name:</label> <input id="lastNameId" name="lastName" type="text" value=""> </p> </form> The only reason I could see is that <label> is a HTML4 addition, but all modern browsers (IE6, Opera7, Netscape7 are the ones I checked) support it. So having the option to use <label> would be great. It should use <label> when added to Struts.
I agree, I had originally used <SPAN> tags cause <LABEL> does not support
the 'class' and 'style' attributes for Netscape 4.* but I did some research and it looks like IE (5.0, 5.5, & 6.0) has a combined 95% of the market. (http://www.onestat.com/html/aboutus_pressbox15.html) I have made the changes to the LabelTag, but with the release of 1.1 and the flurry of changes to the HTML tag library I will have to wait a bit so I can make a new patch against the latest files. (The real reason for delay is I am leaving today for a two week trip to Germany and I have been running around getting ready for that.) Jonathan I have implemented a slightly modified version of your patch to add "error
styles" to the html tags. There are now 'errorStyle', 'errorStyleClass', 'errorStyleId' and 'errorKey' attributes for the following tags: CheckboxTag, FileTag, MultiboxTag, PasswordTag, RadioTag, SelectTag, TextTag and TextareaTag. The 'errorStyle', 'errorStyleClass' and 'errorStyleId' attributes are equivalents of the 'style', 'styleClass' and 'styleId' attributes for errors (as you had them in your patch). The 'errorKey' attribute is the name of the request scope bean under which the error messages have been stored, with the default being Globals.ERROR_KEY if not specified - works the same as the 'name' attribute on the ErrorsTag. Should be available in the next nightly build (date 4th October 2004) if you want to test them out, available here: http://cvs.apache.org/builds/jakarta-struts/nightly/ Niall Just today I was wondering about using the label tag, and I'm wondering what the
current status of this ticket is. It seems as though some parts of this were already implemented, but what about html:label itself? Was there a reason not to do it, or is it just that no one has gotten to it? Is there any reason not to mark STR-1305 a duplicate of this one and leave this as the nexus for discussion of support for the HTML 4 <LABEL> tag? If the proposed <html:label> field does not output a label, I say this does not exactly fit into the HTML tag library family. Also the problem with this ticket is that it is trying to solve two different problems: (1) default error styles in a properties file and then (2) create a new label tag.
STR-1305 specifically deals with the use of <html:label> outputting the HTML label. STR-1525 (this ticket) should only deal with a default error style. Unless somebody objects, I will develop the <html:label> under STR-1305 leaving this for the default error style enhancement. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Complete Diff Report (all changes except the new LabelTag)