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

Custom conversion in FXML

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8u45
    • Fix Version/s: tbd
    • Component/s: javafx
    • Labels:
      None
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      FXML can invoke some conversions on the fly when using binding expressions, e. g. text="${a.b}") will convert getB(s) value into a String if it is not already a String. In real world applications there often is a need to use custom conversions. For example, when a domain model provides instances of "Fruit" typically you don't want to have the toString conversion result on the screen (i. e. FRUIT) but actually you like to get the localized result (i. e. "Fruit" in English or "Frucht" in German).

      Unfortunately there is no way to specify this common need in pure FXML. Not even is there a Bindings.convert() variant that allows to specifiy either a custom StringConverter to support this common need.

      Hence I'd like to suggest that (a) there should be an additional Bindings.convert(ObservableValue, StringConverter customConverter) method, and (b) FXML should be able to invoke _explicitly_specified_ static Bindings methods (i.e. text="${convert(a.b, customConverter)}").

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            mkarg Markus Karg
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: