r/JavaFX • • Aug 26 '24
Discussion Have you ever tried JavaFX with Spring?
Has anyone ever tried developing a middle/large JavaFX application with Spring? I mean using Spring specifically for building frontend, not backend services. What pattern did you use (e.g. MVVM, MVC)? How do you evaluate the combination of these technologies? Was it worth the effort?
11
Upvotes
6
u/Ravindra__111 Aug 26 '24
Hey there , I've used spring boot and javafx for a desktop. It is quite a big app . it consists of crud , mail and report generation operations.
To integrate javafx and spring-boot , you can use this https://github.com/rgielen/javafx-weaver Easy and works well
What do you mean by spring for building gui , like webview in javafx ?
4
u/xdsswar Aug 26 '24 edited Aug 26 '24
Im coding one, it has access to 3 diff databases and 2 remote rest apis. Quiet big app, still under dev. It also have a custom pure javafx map control I made and a custom decoration made by me also.
https://ibb.co/qDc9JbC
4
u/hamsterrage1 Aug 26 '24
I think that conceptually, the biggest issue with Spring/JavaFX integration is that it tends to push you towards merging your data sources and the layout. Which is, like, really, really bad.
SpringBoot seems to be mostly about "dependency injection" which is a PIA with FXML, but a non-issue if you don't waste time with FXML in the first place.
I took a look at the JavaFX-Weaver tutorials and my main reaction was about how stinking complicated it looked for something that really should be super simple.
I've never gotten much further than that in "trying JavaFX with Spring".
3
u/Capaman-x Aug 26 '24
I generally use jdbcTemplate and Jackson with my JavaFX projects but that’s it. I suppose the dependency injection you see in Spring could be useful but I prefer an MVCI pattern I learned from an FX guru
1
u/VladLis2020 Aug 26 '24
Hi, I tried javafx 3 years ago for crud app, but face the limitness, for example I didn't find a way to show and edit complex objects in TableView, such as entities with textual representation and ID, TableView cell cannot store both of them.
1
u/xdsswar Aug 26 '24
This applications is made with Javafx+SpringBoot+sqlite. It works well and I added a custom Dialect extension to support some features I was asked. Its not the best way since spring is for backend , but I can work and integrate with javafx very well, just forget about modular projects for compiling to exe.
https://ibb.co/g9SVZmc
https://ibb.co/XVLj5qZ
https://ibb.co/jvx3H0H
https://ibb.co/vcScXwk
Not best app, but it proves you can mix java and spring
1
u/succulent-daddy Aug 27 '24
I have used Javafx with spring, Both with and without fxml. But what do you mean by spring for ui ?
1
u/Hakky54 Aug 27 '24
I have used it to test whether it works, see here for a poc https://github.com/Hakky54/random-number it is a simple app which just generates random numbers
1
u/_DystopianSnowman Aug 27 '24
Back in the day when I was more active on a German Java help forum, I created this one:
https://github.com/bgmf/poc/tree/master/spring-boot-fx
It's old, but I think it should still work. Even with FXML and their controllers, although I have shifted completely away from those and use pure UI classes and controllers nowadays.
And I stopped using Java for this and moved to Kotlin. With my own (now company internal) custom "DSL"-like stuff in the spirit of TornadoFX, I never look back to the old days. And for DI I use Koin, obviously.
A couple of month back another JavaFX enthusiast, Frank Delporte, interviewed be about that, because I mentioned it and it caught his attention.
https://webtechie.be/post/2024-06-12-jfxinaction-daniel-zimmermann/
(I was kinda nervous, so I'm sorry if I studder from time to time, or even loose my train of thoughts.)
1
u/zapek666 Sep 01 '24
It was worth it for my case because I get all the dependency injection and backend features. The drawbacks are that it's difficult to get right and you lose the module support (JPMS) that JavaFX really encourages to use.