History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GRAILS-983
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Graeme Rocher
Reporter: Marc Palmer
Votes: 0
Watchers: 0
Operations

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

Problems with case of tag names in taglibs

Created: 27/Mar/07 07:39 AM   Updated: 13/Feb/08 03:17 AM
Component/s: TagLib
Affects Version/s: 0.4.2
Fix Version/s: 1.1

Time Tracking:
Not Specified


 Description  « Hide
There seems to be a problem with case conversion of taglib tag names.
/**
     * Usage: 
     * <g:hcard orgName="Enotions Ltd." poBox="PO BOX 9999" locality="Somewhere" postCode="XX99 Y123"/>
     */
	def hCard = { attrs ->
		out << """
		out << """
<div class="vcard">
<p class="adr">
<span class="fn org"><span class="organization-name">${attrs.orgName}</span></span><br />
<span class="post-office-box">${attrs.poBox}</span><br />
<span class="locality">${attrs.locality}</span><br />
<span class="postal-code">${attrs.postCode}</span>
</p>
</div>
		"""
}

This code will not invoke with <g:hCard> or <g:hcard> You must change the name of the tag to all lowercase for it to work, and then it only works as <g:hcard>



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Lee Butts - 12/Feb/08 05:52 PM
I had a look into this issue and it's caused by the property discriptors returned by spring.

def hCard is interpreted as a property called 'HCard' where as def hcard is correctly interpreted as 'hcard'. Not sure how to get around this. It's possibly caused by the way that groovy generates getter and setters names as the BeanInfo object contains setHCard/getHCard which I think is what confuses spring.

cheers

Lee


Marc Palmer - 13/Feb/08 03:17 AM
Curiouser and curioser.

Because the Java beans spec mandates that a property name with two capitals at the start must have those left intact.

So, as far as I understand it, Groovy and Spring are possibly at fault here. Normally this property munging of beans is transparent but in this first letter lower, second letter caps scenario it looks like it is falling apart.

Groovy converting hCard to setHCard and getHCard is correct but possibly naive. The rule on double caps at start of property name not being lowercased perhaps needs a reverse counterpart where names with a single lowercase and then caps letter are not changed when generating getters/setters.

Even then, with sethCard and gethCard, Spring should be returning the name as hCard but it appears to be lowercasing it all, which seems to violate the bean naming conventions. i.e. with a property name of ABCD spring should return ABCD according to my understanding of the bean spec, but it looks like (I haven't tried) it will return "abcd".