Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8101199

Low-Level bindings API not usable from Clojure

XMLWordPrintable

      This issue is a response to the blog entry ( http://fxexperience.com/2011/05/javafx-2-0-beta-is-available/ ) by Richard, Jasper and Jonathan, where they asked to file Jira issues with use cases that the current API prohibits. One such case I just discovered while trying to port JavaFX-Script-like bindings to Clojure.

      From the example JFX-Script code I saw about bindings it seems to me that it would be possible to do something like this:

      def text = TextBox;
      ...
      Label {text: bind text.rawText.toUpper() }

      When one types in the TextBox "text" it immediately the Label with the identical text, but all upper case. After reading the docs for DoubleBinding I tried to do this in Clojure, unfortunately without success. When I did this in Java however it worked. I attached an example code file.

      The challenge here is the following combination: a subclass needs to be made & an anon constructor is used & a protected method is called.
      It is always a bit cumbersome when subclassing is required, but Clojure offers the proxy macro for that which generates such a subclassed instance. But inside this proxy I can not create an anon constructor, such as { super.bind(myProperty); }. Plus bind() is a protected method which also can not be called from a proxy class.
      This could perhaps be solved by making bind public. I could then just subclass a StringBinding and implement its computeValue() method and directly after that call bind() outside. In the attached Java code the line containing { super.bind(tbp); } would be eliminated and directly after instantiating foo one would call foo.bind(tbp);
      Another solution would be that StringBinding becomes an Interface, or a StringBindingITF gets added. The solution with an interface would be even more performant in Clojure.

      I will be happily supporting this issue by testing in Clojure and reporting back, if this is required and if you decide to work on this issue.

            mheinrichs Michael Heinrichs (Inactive)
            athiemejfx Andre Thieme (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: