Anyone?

Does the struts tags do some reflection magic that bypass the Groovy MetaClass?


On Nov 9, 2009, at 5:55 PM, Ronny Løvtangen wrote:


How can I from a Struts tag access properties that is overridden by Groovy meta programming?
Example:

Bar.groovy
---------------

class Bar {
        String baz
}



FooAction.groovy
-------------------------

class FooAction extends ActionSupport {

        Bar bar

        String retrieveBar() {
                bar = new Bar(baz: "original value")
                bar.metaClass.getBaz = {"new value"}
                return SUCCESS
        }
}

foo.jsp
--------

<%@ taglib prefix="s" uri="/struts-tags" %>
Baz is: <s:property value="bar.baz"/>




Which yields the output  "Baz is: original value"

I was expecting "Baz is: new value", which is true for this test:


class FooActionTest extends GroovyTestCase {

        void testRetrieveBar() {
                FooAction action = new FooAction()
                action.retrieveBar()
                assertEquals "new value", action.bar.baz
        }
}


Any idea on how I from a Struts tag can invoke the overridden getBaz method instead of the original one?


Ronny

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



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

Reply via email to