MVVM pattern in java

29.6k views Asked by At

I want to make a mvvm project on java. But I can not find a sample project. There are a few Android samples but I don't want to make an Android-project. So how can I make a project with the mvvm pattern?

I am trying to create a desktop application on which there are combo boxes and a data-grid. The app must connect to a database (i.e. MySQL) and the data-grid must be filled with data. Any changes on the combo boxes must change the grid's content. Maybe I want to make CRUD-operation on later steps.

So any suggestions...

2

There are 2 answers

1
nowaq On

Take a look at JavaFX framework. It was already mentioned in a couple of other stackoverflow questions:

You may also find this blog post very interesting. It mentions Presentation Model (a pattern highly related to MVVM) and walks you trough basic JavaFX concepts regarding FXML (smth. like XAML in WPF).

EDIT: Simmilar question on stackoverlow

Is there anything similar to WPF and MVVM in Java world?

2
simbo1905 On

In 2012 I published an article on a Java framework doing MVVM ("presentation model"), MVP ("passive view") and a hybrid MVVMP/MVC ("supervising controller") on the IBM developer website. In 2023 the link was broke. Here is a copy shared out of my personal Dropbox folder:

Implementing event-driven GUI patterns using the ZK Java AJAX framework

It has full source code which deployed on three different PaaS cloud services over at github.

The source code has links to demos that worked in 2012 running on free tier cloud providers. Those were shut down some time in the past decade.