This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-10-02
Channels
- # announcements (15)
- # aws-lambda (1)
- # babashka (2)
- # beginners (25)
- # calva (2)
- # cider (6)
- # cljfx (6)
- # clojure (24)
- # clojure-boston (1)
- # clojure-dev (2)
- # clojure-europe (31)
- # clojure-uk (2)
- # clojurescript (48)
- # community-development (4)
- # conjure (1)
- # datahike (4)
- # datascript (10)
- # datomic (1)
- # deps-new (1)
- # fulcro (10)
- # juxt (1)
- # malli (7)
- # missionary (1)
- # nrepl (2)
- # off-topic (2)
- # other-languages (5)
- # polylith (4)
- # random (1)
- # react (2)
- # shadow-cljs (9)
- # tools-deps (21)
I've got a TextField with a formatter, which is rendered dynamically, and the specific formatter can change. When this happens I seem to get clojure.lang.ExceptionInfo: Replace forbidden {:old-value :long, :new-value :double}
. Am I doing something wrong? It's a child in a list so I assume the instance is being reused and it's difficult to atomically set formatter and value all at once (although I'm using the value key inside the text formatter).
Replaces are forbidden in cases where the value is a constructor argument that cannot be changed later, i.e. there is just no way to mutate the object to set the value to a new one
Here are the docs for TextFormatter: https://openjfx.io/javadoc/14/javafx.controls/javafx/scene/control/TextFormatter.html As you can see, it has filter as an argument, but no setters to change it afterwards
The workaround is to re-create the whole text formatter when you want to change its filter
There is an extension lifecycle that does that, described here: https://github.com/cljfx/cljfx/issues/76#issuecomment-645563116