My version:
<dependency>
<groupId>com.dlsc.formsfx</groupId>
<artifactId>formsfx-core</artifactId>
<version>1.3.1</version>
</dependency>
For example:
import com.dlsc.formsfx.model.structure.Field;
import com.dlsc.formsfx.model.structure.Form;
import com.dlsc.formsfx.model.structure.Group;
import com.dlsc.formsfx.view.renderer.FormRenderer;
import javafx.application.Application;
import javafx.beans.property.*;
import javafx.collections.FXCollections;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class FormsfxApp extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
StringProperty name = new SimpleStringProperty("my name");
name.addListener((observable, oldValue, newValue) -> System.out.println("new name:" + newValue));
IntegerProperty age = new SimpleIntegerProperty(10);
age.addListener((observable, oldValue, newValue) -> System.out.println("new age:" + newValue));
ObjectProperty<String> selected = new SimpleObjectProperty<>("aaa");
selected.addListener((observable, oldValue, newValue) -> System.out.println("select:" + newValue));
ListProperty<String> items = new SimpleListProperty<>(
FXCollections.observableArrayList("aaa", "bbb", "ccc")
);
Form form = Form.of(
Group.of(
Field.ofStringType(name),
Field.ofIntegerType(age),
Field.ofSingleSelectionType(items, selected)
)
).title("test persist");
BorderPane borderPane = new BorderPane();
borderPane.setCenter(new FormRenderer(form));
primaryStage.setScene(new Scene(borderPane, 1000, 600));
primaryStage.show();
}
}

Other Fields like StringField and IntegerField change property only when form.persis() is called explicitly. But selected property in SingleSelectionField is eagerly modified in every time I select other item in combo box.
I find there is a persistentSelection field in SingleSelectionField:
|
protected final ObjectProperty<V> persistentSelection = new SimpleObjectProperty<>(); |
But why it is not exposed for user?
My version:
For example:
Other Fields like
StringFieldandIntegerFieldchange property only whenform.persis()is called explicitly. Butselectedproperty inSingleSelectionFieldis eagerly modified in every time I select other item in combo box.I find there is a
persistentSelectionfield inSingleSelectionField:FormsFX/formsfx-core/src/main/java/com/dlsc/formsfx/model/structure/SingleSelectionField.java
Line 50 in cf37703
But why it is not exposed for user?