Thinking about this some more... you could contribute a mixin to render an id, 
of course, but that's time consuming and has problems if you're relying on, eg, 
generated forms via bean editor and the like.
However... (and you've probably already thought of this, but...) you should be 
able to restore, globally, the old behavior.  Here's how.

Contribute to the MarkupRenderer pipeline:
public void contributeMarkupRenderer(OrderedConfiguration<MarkupRendererFilter> 
config) {
        MarkupRendererFilter generateLabelId = new MarkupRendererFilter() {
                public void renderMarkup(final MarkupWriter writer, 
MarkupRenderer renderer) {
                        MarkupWriterListener labelListener = new 
MarkupWriterListener() {

                                        public void elementDidEnd(Element 
element) {
                                                if 
("label".equals(element.getName())) {
                                                        
element.attribute("id",element.getAttribute("for") + "-label");
                                                }
                                        }

                                        public void elementDidStart(Element 
element) {}
                                
                        };
                        writer.addListener(labelListener);
                        renderer.renderMarkup(writer);
                        writer.removeListener(labelListener);
                }
        };
        config.add("LabelId", generalLabelId, "before:*");
}


That's untested code, and you would probably want more sanity checking in the 
elementDidEnd method, but that general idea should work.
You could use the same idea (possibly) to convert _ back to -; just update the 
id attribute.

HTH,

Robert

On Dec 17, 2010, at 12/1711:10 AM , Blower, Andy wrote:

> Thanks for the reply Andreas,
> 
> I wouldn't call it redundant myself, that expression is not anywhere near as 
> efficient as finding the tag in the dom using an id.
> 
> 
>> -----Original Message-----
>> From: andre...@gmail.com [mailto:andre...@gmail.com] On Behalf Of
>> Andreas Andreou
>> Sent: 17 December 2010 16:51
>> To: Tapestry users
>> Subject: Re: [T5.2] Label tags not getting id attribute rendered, why?
>> 
>> It makes sense to me to not output redundant html....
>> And if you know the id of the control you can get to its label by
>> $$('label[for=' + id + ']')
>> 
>> On Fri, Dec 17, 2010 at 18:35, Blower, Andy
>> <andy.blo...@proquest.co.uk> wrote:
>>> The change was made in July and doesn't appear to be associated with
>> a JIRA:
>>> 
>>> r931361 | hlship | 2010-04-07 00:01:00 BST
>>> 
>>> Do not render an id attribute for Label components, as they can be
>> identified via their for attribute
>>> 
>>> 
>>> Yes they can, but it's pretty standard to find tags in the dom via
>> id's, especially when using prototype.
>>> 
>>> Howard, can you explain why this change was necessary, and the
>> thinking behind it.
>>> 
>>> Unfortunately this change has broken our client side validation error
>> messages. We only noticed yesterday. The change immediately before it
>> changed the - to a _ before the 'label' suffix. I'd like to know why
>> this was done before I raise a JIRA.
>>> 
>>> Thanks,
>>> 
>>> Andy.
>>> 
>> 
>> 
>> 
>> --
>> Andreas Andreou - andy...@apache.org - http://blog.andyhot.gr
>> Tapestry PMC / Tacos developer
>> Open Source / JEE Consulting
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to