<div dir="ltr">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.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jan 22, 2023 at 2:08 AM Thiago Milczarek SayĆ£o <<a href="mailto:thiago.sayao@gmail.com">thiago.sayao@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi,</div><div><br></div><div>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).</div><div>It Would be very useful if we could just copy database mapped objects to javafx observables and say: Display it on a tableview.</div><div>Configuration of each column would be done as an annotation, like this:</div><div><br></div><div><div style="background-color:rgb(30,31,34);color:rgb(206,208,214);font-family:"JetBrains Mono",monospace"><pre><span style="color:rgb(116,157,237)">public class </span>EmployeeObservable {<br> @Column(<span style="color:rgb(177,137,245)">label </span>= <span style="color:rgb(126,196,130)">"Registration"</span>, <span style="color:rgb(177,137,245)">style </span>= <span style="color:rgb(126,196,130)">"-fx-alignment: right"</span>)<br> <span style="color:rgb(116,157,237)">private </span>IntegerProperty <span style="color:rgb(114,207,214)">registration </span>= <span style="color:rgb(116,157,237)">new </span>SimpleIntegerProperty();<br><br> @Column(<span style="color:rgb(177,137,245)">label </span>= <span style="color:rgb(126,196,130)">"Name"</span>)<br> <span style="color:rgb(116,157,237)">private </span>StringProperty <span style="color:rgb(114,207,214)">name </span>= <span style="color:rgb(116,157,237)">new </span>SimpleStringProperty();<br><br> @Column(<span style="color:rgb(177,137,245)">label </span>= <span style="color:rgb(126,196,130)">"Salary"</span>, converter = BigDecimalCurrencyConverter.<span style="color:rgb(116,157,237)">class</span>)<br> <span style="color:rgb(116,157,237)">private </span>ObjectProperty<BigDecimal> <span style="color:rgb(114,207,214)">salary </span>= <span style="color:rgb(116,157,237)">new </span>SimpleObjectProperty<>();<br><br> <span style="color:rgb(111,115,122)">//boilerplate here<br></span>}</pre></div></div><div><br></div><div>Other annotation options:</div><div><div style="background-color:rgb(30,31,34);color:rgb(206,208,214);font-family:"JetBrains Mono",monospace"><pre>@Column(<span style="color:rgb(177,137,245)">ignore </span>= <span style="color:rgb(116,157,237)">true</span>)<br><br>@Column(graphicsConverter = CheckBoxGraphicsConverter.<span style="color:rgb(116,157,237)">class</span>)</pre></div></div><div>And to apply it:</div><div><div style="background-color:rgb(30,31,34);color:rgb(206,208,214);font-family:"JetBrains Mono",monospace"><pre>TableViewBuilder<EmployeeObservable> <span style="color:rgb(114,207,214)">builder </span>= <span style="color:rgb(116,157,237)">new </span>TableViewBuilder<>(tableView, EmployeeObservable.<span style="color:rgb(116,157,237)">class</span>);<br>builder.build();</pre></div></div><div><br></div><div>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.</div><div><br></div><div>I'm not sure if it would go in a general purpose toolkit, but I thought it would be nice to share (the idea). <br></div><div><br></div><div>-- Thiago.<br></div><div><br></div></div>
</blockquote></div>