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

Key: GRAILS-3117
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Graeme Rocher
Reporter: Chet Seidel
Votes: 0
Watchers: 1
Operations

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

Use of writeEntireProperty attr for tag pageProperty results in a grails runtime exception

Created: 15/Jun/08 07:28 AM   Updated: 15/Jun/08 01:30 PM
Component/s: TagLib
Affects Version/s: 1.0.3
Fix Version/s: 1.0.4

Time Tracking:
Not Specified

Environment: Windows XP


 Description  « Hide
The view/layouts/main.gsp contains the following body tag

<body ${pageProperty(name:'body.style',writeEntireProperty:'true')}>

and the views/classname/list.gsp body is created as

<body style="text-align:center;">

which results in the following runtime exception

No such property: propertyName for class: org.codehaus.groovy.grails.plugins.web.taglib.RenderTagLib

groovy.lang.MissingPropertyException: No such property: propertyName for class: org.codehaus.groovy.grails.plugins.web.taglib.RenderTagLib
at C_mygrails_grails_app_views_layouts_main_gsp.run(C_mygrails_grails_app_views_layouts_main_gsp:27)

Problem appears to be in the pageProperty closure of RenderTagLib where propertyName is used before being defined. This worked for me:

def pageProperty = { attrs ->
            if(!attrs.name) {
	            throwTagError("Tag [pageProperty] is missing required attribute [name]")
            }
            // added by Chet  to fix run time exception
            String propertyName = attrs.name
            // end added by Chet
            def htmlPage = getPage()

            String propertyValue = htmlPage.getProperty(attrs.name)

            if (!propertyValue)
                propertyValue = attrs.'default';

            if (propertyValue) {
                if (attrs.writeEntireProperty) {
                    out << ' '
                    out << propertyName.substring(propertyName.lastIndexOf('.') + 1)
                    out << "=\"${propertyValue}\""
                }
                else {
                    out << propertyValue
                }
            }
    }

As a workaround I might also change the main.gsp to read

<body style="${pageProperty(name:'body.style')}">

Also the documentation for the pageProperty tag (http://docs.codehaus.org/display/GRAILS/GSP+Tag+-+pageProperty) does not mention the writeEntireProperty attr at all. See http://www.opensymphony.com/sitemesh/tags.html#decorator:getProperty



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
There are no comments yet on this issue.