groovy
  1. groovy
  2. GROOVY-1239

Builders: calls to owner methods from within nested closures lead to markup instead of method calling

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0-JSR-4
    • Fix Version/s: 1.0-JSR-5
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      This seems similar to a problem I experience with SwingBuilder.. where
      a change made it impossible to call methods from inside the builder.
      To fix it i had to do something like:

      def self = this

      swing {
      button(action:

      { self.someMethod() }

      )
      }

      void someMethod() {
      // the method
      }

      Note the above is just psuedo code from memory but the problems seem similar

      Graeme

      On 11/02/06, Dierk Koenig <dierk.koenig@canoo.com> wrote:
      > Hi,
      >
      > the following Groovlet runs fine
      > ----
      > html.html{
      > head

      { > title 'Groovlet Demonstrator' > }
      > content()
      > }
      > void content() { > html.body 'Welcome' > }
      > ----
      >
      > This fails:
      > ----
      > html.html{
      > head {> title 'Groovlet Demonstrator'> }

      > p

      { content() }

      // <- mind the p{}
      > }
      >
      > void content()

      { > html.body 'Welcome' > }

      > ----
      >
      > It produces:
      > ----
      > <html>
      > <head>
      > <title>Groovlet Demonstrator</title>
      > </head>
      > <p>
      > <content />
      > </p>
      > </html>
      > ----
      >
      > Logs are empty.
      >
      > Has anybody an idea? Has it anything to do with the latest
      > changes to Closures?
      >
      > cheers
      > Mittie
      >

        Activity

        Hide
        John Wilson added a comment -

        Fixed by a change to MetaClassImpl

        Show
        John Wilson added a comment - Fixed by a change to MetaClassImpl
        Hide
        Dierk König added a comment -

        runs fine.
        added test in BuilderSupportTest:


        void testNestedMethodCallsResolution() {
        def b = new SpoofBuilder()
        b.outest {
        b.outer

        { nestedBuilderCall(b) }

        }
        assert b.log.contains('inner')
        }

        void nestedBuilderCall(builder)

        { builder.inner() }

        also tested initial examle with MarkupBuilder.

        Show
        Dierk König added a comment - runs fine. added test in BuilderSupportTest: void testNestedMethodCallsResolution() { def b = new SpoofBuilder() b.outest { b.outer { nestedBuilderCall(b) } } assert b.log.contains('inner') } void nestedBuilderCall(builder) { builder.inner() } also tested initial examle with MarkupBuilder.

          People

          • Assignee:
            John Wilson
            Reporter:
            Dierk König
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: