r/JavaFX • u/Ok_Jackfruit_6541 • Jun 15 '23
Help Need suggestions for POS system
Hello, everyone!
I hope you're all doing well. I have developed a REST API backend service for my own restaurant and now I want to create a desktop application for this system. I would like the following features to be a part of my desktop application:
- Role-based authorization and page views.
- JWT token-based authentication and authorization.
- Routing for different page views.
I understand that these requirements resemble those of Angular or React applications, and that's accurate. What I'm looking for is a desktop application that functions similarly to a frontend JavaScript application.
My question is: Does JavaFX provide any support for routing and auth guard for page navigation? If it does, could you please guide me on where to start learning about it?
Thank you.
View all comments
Show parent comment
2
u/hamsterrage1 Jun 26 '23
That's the problem! Business logic does NOT go in the ViewModel - it goes in the Model. This is the problem with mvvmfx, it use the WRONG design for MVVM, by assuming that a bunch of POJO DTO objects constitute the "Model", and then - by necessity - putting the business logic in the ViewModel.
Even if you argued that, "OK, it's not technically MVVM, but it still is a workable framework", you have problems. All of these frameworks are supposed to isolate the business logic from the GUI. Once you start putting business logic in the ViewModel, and calling services directly from the ViewModel, you've lost that isolation.
This is literally the entire point behind MVVM, and the reason that it's a pain to use. Domain Objects can't be passed into the ViewModel, and Presentation Model objects cannot be passed into the Model. You need to build an interface between the ViewModel and the Model to allow information from the Presentation Model to passed to the Model, to invoke business logic, and to pass information from the Domain Objects (or anything derived from the business logic) back to the ViewModel.
But don't believe me, go look at the links I posted above. Look at what MicroSoft says - and they created MVVM.