Karthik
Karthik

Reputation: 979

Refresh data in MVVM page after modal close (written in MVC)

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?

Upvotes: 1

Views: 1826

Answers (2)

AlexGreg
AlexGreg

Reputation: 838

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.

Upvotes: 0

chillworld
chillworld

Reputation: 4277

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.

Upvotes: 3

Related Questions