Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-5837

Griffon bind using parentheses fails silently or with cryptic message

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 2.0.6
    • None

    Description

      If a Griffon user accidentally replaces curly braces {} with parentheses () in a call to bind, the error either fails silently at runtime or with a cryptic compiler error (depending on the widget type).

      In the sample code (attached), the first textfield and button work correctly. The 2nd textfield (error #1) fails silently (it is blank, no compiler warnings). If uncommented, the 2nd button (error #2) causes a cryptic runtime exception (java.lang.NullPointerException - see full stacktrace attached).

      Sample Griffon code for project "bug":

      -- BugView.groovy ----------------------------------------------
      package bug
      
      def makeText = { phrase ->
        textField( columns:10,    text: bind { phrase.insect  } )  // correct
        button(    "Larvae",   enabled: bind { phrase.enabled } )  // correct
        textField( columns:10,    text: bind ( phrase.insect  ) )  // error #1 - silent failure
        // button(    "Larvae",   enabled: bind ( phrase.enabled ) )  // error #2 - compiler error
      }
      
      def val = 1
      application( title: 'bug', preferredSize: [320, 240], pack: true, location: [50,50],
                   iconImage: imageIcon('/griffon-icon-48x48.png').image
                 ) {
        borderLayout()
        panel( constraints: CENTER, border: titledBorder(title: 'Bug Test')) {
          widget( makeText( model."data${val}" ) )
        }
      }
      
      -- BugModel.groovy ----------------------------------------------
      package bug
      import groovy.beans.Bindable
      
      @Bindable 
      class BugModel {
        Map data1 = [ insect:"Buggy Text", buggyFlag: true ] as ObservableMap
      }
      

      Attachments

        1. BugView.groovy
          0.7 kB
          Alan Thompson
        2. BugModel.groovy
          0.1 kB
          Alan Thompson
        3. buggy.png
          105 kB
          Alan Thompson
        4. BugController.groovy
          0.1 kB
          Alan Thompson
        5. bug.out
          19 kB
          Alan Thompson

        Activity

          People

            aalmiray Andres Almiray
            thompson2526 Alan Thompson
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: