Issue Details (XML | Word | Printable)

Key: TAPESTRY-974
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Jesse Kuhnert
Reporter: Matt Raible
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Tapestry

Modify ValidationDelegate or FieldLabel so it allows markup to be written inside <label>

Created: 02/Jun/06 05:29 AM   Updated: 29/Nov/06 03:07 AM
Return to search
Component/s: Framework
Affects Version/s: 4.0.2
Fix Version/s: 4.1.1

Time Tracking:
Not Specified

File Attachments:
  Size
Java Source File Licensed for inclusion in ASF works FieldLabel.java 2006-06-02 05:31 AM Matt Raible 2 kB

Resolution Date: 29/Nov/06 03:07 AM


 Description  « Hide
Copied from the following thread:

http://www.nabble.com/Issues+with+Label+Components+with+Tapestry+4.0-p4576155.html

<issue>
I'm overriding ValidationDelegate in order to add required field
indicators. I used to be pre-pending an asterisk to the beginning of
the field, and I had that working. Now I want to add <span class="req">
to the end of the <label> before the </label> shows up. I'm using
@FieldLabel and everything *almost* works. I've eliminating error
styling in the class below so it's easier to read.

public class Validator extends ValidationDelegate {
    public void writeLabelSuffix(IFormComponent component,
                                 IMarkupWriter writer, IRequestCycle
cycle) {
        if (component.isRequired()) {
            writer.begin("span");
            writer.attribute("class", "req");
            writer.printRaw(" *");
            writer.end();
        }
    }

The code above results in <label>blah blah</label><span class="req">
*</span>, when I'd rather have the <span> w/in the <label>. I tried
overriding writeLabelAttributes(), but that doesn't seem to allow me to
create a new tag and write it out w/in the label.
</issue>

The only way to achieve this functionality currently is to override FieldLabel and change the order of when things are written. I'll attach my custom FieldLabel to demonstrate the functionality I'm looking for.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Matt Raible added a comment - 02/Jun/06 05:31 AM
While I don't mind providing my own custom FieldLabel, it is unfortunate that I have to copy ValidMessages.java from the Tapestry source tree. This file is package-protected, so it has no visibility to classes outside of Tapestry.

Jesse Kuhnert added a comment - 29/Nov/06 03:07 AM
Added two new methods to IValidationDelegate as I couldn't be sure this wouldn't screw too many other people up. They are called beforeLabelText and afterLabelText.