是否可以使用@NotifyChange而不是BindUtils.postNotifyChange? [英] Is it possible use @NotifyChange instead of BindUtils.postNotifyChange?

查看:289
本文介绍了是否可以使用@NotifyChange而不是BindUtils.postNotifyChange?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在@NotifyChange和BindUtils.postNotifyChange之间有一个混淆,为什么要使用这两个事件。之前我读过这个问题
在ZK中我们可以PostNotifyChange多个变量
但是我无法理解这个问题为什么要使用这个多个变量。

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.

这是一个例子:

    @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;
        }
    }

任何人都可以告诉我:

我有四个问题:

1.为什么在@NotifyChange中使用isDisabled?

1.Why use isDisabled in @NotifyChange ?

2.在这种方法中,我可以使用@NotifyChange而不是BindUtils.postNotifyChange?

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

3. @NotifyChange和BindUtils.postNotifyChange之间有什么区别?

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

4.我想在方法中只使用这两个@NotifyChange和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 ?

推荐答案

1)如果此调用在任何情况下都没有更改与isDisabled相关联的变量,则不需要。

但也许它在中更改了loadFolderInfoList()

2)你可以想象一个 @NotifyChange({arg1,arg2,...,argN})

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)但你可以调用 BindUtils.postNotifyChange( ...)来自所有地方,只要你有一个对VM的引用。

4)对我看来这个代码来自嵌套类 FolderInfoEditViewModel ,它本身就是VM以及 FolderInfoEditViewModel

在这种情况下为嵌套类调用@NotifyChage(...)但是

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");

指的是外部类 FolderInfoEditViewModel 并且只能以这种方式存档。

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

这篇关于是否可以使用@NotifyChange而不是BindUtils.postNotifyChange?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆