I have a MVVM dialog which lists the users from the DB. There is an add button on click, it opens a modal (which is in MVC). On addition of a user, the modal closes. But the user added is not populated in the parent dialog which called the add user modal. Is there any way to populate the MVVM on data change without needing to call another method or refresh the page?
Asked
Active
Viewed 1,759 times
2 Answers
3
You could use a Global-Command
.
just before you close the modal window :
BindUtils.postGlobalCommand(null,null,"refreshUsers",null);
and in your ViewModel of the user list :
@GlobalCommand
@NotifyChange("users")
public void refreshUsers(){}
Note : I'm assuming you have a method getUsers
. otherwise rename users
to the correct getter of your users.

chillworld
- 4,207
- 3
- 23
- 50
0
In your view model, instead using java.util.List
for your users, you could simply use org.zkoss.zul.ListModelList
in this way, adding or removing items to your ListModelList will cause the update of your listbox or grid accordingly.

AlexGreg
- 838
- 10
- 22
-
Indeed and you could give the new user to the global-command in the map. (wanted to keep mine answer simpel and working) – chillworld Aug 07 '14 at 12:16
-
There are multiple solutions possible. You can Always post yours here so the OP has multiple choices. – chillworld Aug 08 '14 at 17:31