Frage

I have one confusion use between @NotifyChange and BindUtils.postNotifyChange ,Why use this two event .Before i read this question In ZK Can we PostNotifyChange more than one variables . But i cant understand this question why use this more than one variable.

Here's an example:

    @Command
    @NotifyChange({ "folderInfoList", "isDisabled", "selectedFolderInfo" })
    public void refreshFolderInfo() {
        logger.debug("Refresh Icon selected");
        if (isDirty()) {
            Messagebox.show(pageResourceBundle.getText("JS_CONFIRM_DATAMODIFED"), pageResourceBundle.getText("JS_CONFIRM_DATAMODIFED_TYPE"),
                    Messagebox.OK | Messagebox.CANCEL, Messagebox.QUESTION, new EventListener<Event>() {
                        public void onEvent(Event event) throws Exception {
                            if (Messagebox.ON_OK.equals(event.getName())) {
                                loadFolderInfoList();
                                selectedFolderInfo = null;
                                BindUtils.postNotifyChange(null, null, FolderInfoEditViewModel.this, "folderInfoList");
                            } else {

                            }
                        }
                    });
        } else {
            loadFolderInfoList();
            selectedFolderInfo = null;
        }
    }

Can anybody tell me:

I have four question :

1.Why use isDisabled in @NotifyChange ?

2.Here this method i can use @NotifyChange instead of BindUtils.postNotifyChange ?

3.What is the difference between @NotifyChange and BindUtils.postNotifyChange ?

4.I want to use only one event between this two @NotifyChange and BindUtils.postNotifyChange in method .Is it possible for this method ?

War es hilfreich?

Lösung

1) If the variable associated with "isDisabled" is not changed in any case by this call, you don't need to.
But maybe it is changed inside loadFolderInfoList()
2) You can imagine that a @NotifyChange({"arg1","arg2",...,"argN"}) is the same as

for(String arg : args){ 
  BindUtils.postNotifyChange(null, null, refToClassCalledFrom, arg); 
}

3) But you can call BindUtils.postNotifyChange(...) from everywhere as long as you got a reference to the VM.
4) To me it looks like this code is from a nested class of FolderInfoEditViewModel, that it self is is VM as well as FolderInfoEditViewModel.
In this case the @NotifyChage(...) is invoked for the nested class but

BindUtils.postNotifyChange(null, null, FolderInfoEditViewModel.this, "folderInfoList");

refers to it's outer class FolderInfoEditViewModel and that can only be archived this way.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top