TableViewBuilder idea
Thiago Milczarek Sayão
thiago.sayao at gmail.com
Sun Jan 22 15:54:03 UTC 2023
Probably goes on a library. But it would also be nice to have to boost
productivity on enterprise applications, boosting JavaFX adoption.
The idea is not to map directly to JavaFX observables because it would
imply importing it on the "backend logic". But just copy from a DTO to an
observable class and the UI would auto-update.
It can come from a database or a web-service.
-- Thiago
Em dom., 22 de jan. de 2023 12:46, Nir Lisker <nlisker at gmail.com> escreveu:
> Isn't this something that an external library can do? I would think that
> writing an adapter that can read JPA annotations is the way to go. After
> all, most entities are not written with JavaFX properties.
>
> On Sun, Jan 22, 2023 at 2:08 AM Thiago Milczarek Sayão <
> thiago.sayao at gmail.com> wrote:
>
>> Hi,
>>
>> TableView data usually comes from a database and is mapped to java
>> objects (I don't have actual statistics on this but it's probably a true
>> assertion).
>> It Would be very useful if we could just copy database mapped objects to
>> javafx observables and say: Display it on a tableview.
>> Configuration of each column would be done as an annotation, like this:
>>
>> public class EmployeeObservable {
>> @Column(label = "Registration", style = "-fx-alignment: right")
>> private IntegerProperty registration = new SimpleIntegerProperty();
>>
>> @Column(label = "Name")
>> private StringProperty name = new SimpleStringProperty();
>>
>> @Column(label = "Salary", converter = BigDecimalCurrencyConverter.class)
>> private ObjectProperty<BigDecimal> salary = new SimpleObjectProperty<>();
>>
>> //boilerplate here
>> }
>>
>>
>> Other annotation options:
>>
>> @Column(ignore = true)
>>
>> @Column(graphicsConverter = CheckBoxGraphicsConverter.class)
>>
>> And to apply it:
>>
>> TableViewBuilder<EmployeeObservable> builder = new TableViewBuilder<>(tableView, EmployeeObservable.class);
>> builder.build();
>>
>>
>> I actually have implemented this and it's very useful. I can't share it
>> because I've done it for a private company, but it's easy to re-do it.
>>
>> I'm not sure if it would go in a general purpose toolkit, but I thought
>> it would be nice to share (the idea).
>>
>> -- Thiago.
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20230122/34492092/attachment-0001.htm>
More information about the openjfx-dev
mailing list