简体   繁体   English

如何在Java FX中将表单映射到bean

[英]How to map a form to a bean in Java FX

I have a form made with fxml, it has like 20 fields. 我有一个用fxml制成的表单,它有20个字段。 (Ie Person) and I have my controller with the 20 fields (one for every field) o want to know if there is a way to box all these fields in a unique bean like PersonBean. (即Person),我有20个字段(每个字段一个)的控制器。o想知道是否有办法将所有这些字段装在一个像PersonBean这样的独特bean中。 Actually I have to set all the fields to the bean manually in the initialize method. 实际上,我必须在initialize方法中将所有字段手动设置为Bean。

Something like in the Id of the fxml input put something like "person.name". 在fxml输入的Id中输入“ person.name”。

Not 100% sure but try something like: 不确定100%,但可以尝试以下方法:

text="${controller.person.name}"

where person is a property of the controller and name is a property of PersonBean. 其中person是控制器的属性,而name是PersonBean的属性。

See: 看到:

You might need to provide JavaFX properties such as 您可能需要提供JavaFX属性,例如

ObjectProperty<PersonBean> personProperty();
StringProperty nameProperty();

but maybe there is also some support for plain JavaBeans properties. 但是也许对纯JavaBeans属性也有一些支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM