Flex-Mate,如何使用模型返回弹出窗口(对话框)

发布于 2024-08-24 07:03:21 字数 173 浏览 15 评论 0原文

我在 MVC 的 Adob​​e Flex 项目上使用 MATE。在我们的其中一个页面上,我们有一个向用户显示的对话框窗口,向他们显示来自 RPC 的信息。弹出此对话框的页面与显示的数据无关,因此这是一个单独的模型。如何创建 MATE 映射文件来创建对话框窗口,使其对用户可见,然后从模型中注入数据?

感谢您的阅读。

I'm using MATE on an Adobe Flex project for MVC. On one of our pages, we have a dialog window that is presented to the user that displays them information that comes from RPC. The pages where this dialog pops up is unrelated to the data being displayed so this is a separate model. How do I create a MATE mapping file that will create the dialog window, make it visible to the user, and then inject in data from a model?

Thanks for reading.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

热鲨 2024-08-31 07:03:21

似乎您找到了一种方法,但如果您对另一个想法感兴趣,Mate 论坛上有一个非常好的帖子,介绍如何处理 Mate 中的弹出窗口。它包括一些示例代码,并讨论了所涉及的最佳实践以及为什么做出某些选择:

将带有弹出窗口的应用程序转换为 Mate << Mate Forums

如果我理解正确的话,这里有一些代码可以完成您需要的操作(改编自该线程)。它将 RPC 调用的结果注入视图中(使地图不知道视图如何显示该数据),并且视图将在有数据时创建弹出窗口,并在没有数据时删除弹出窗口。该线程对大部分代码有进一步的解释。

事件映射:

<Injectors target="{PopupParentView}">
    <PropertyInjector destinationKey="rpcData" 
                      source="{FooManager}" sourceKey="rpcData" />
 </Injectors>

PopupParentView:
...

private var popup : UIComponent;

private var rpcData : Object;

private function onPreinitialize( event : Event ) : void {
    BindingUtils.bindSetter(rpcDataChanged, this, "rpcData");
}

private function rpcDataChanged( value : Object ) : void {
    invalidateProperties();
}

override protected function commitProperties( ) : void {
    // two mutually exclusive branches: either the property can be interpreted as "show the popup"
    // and the popup doesn't exist, or we shouldn't show the popup, but it does exist. all other
    if ( rpcData != null && popup == null ) {
        popup = PopUpManager.createPopUp(...);
    } else if ( rpcData == null && popup != null ) {
        // make sure to set the popup property to null
            PopUpManager.removePopUp(popup);
            popup = null;
    }
}
</Script>
...

Seems like you found an approach, but if you are interested in another idea, there is a really good thread on the Mate forums about how to approach popups in Mate. It includes some example code and discusses the best practices involved and why certain choices are being made:

Converting app with popups to Mate << Mate Forums

If I understand you correctly, here is some code to do what you need (adapted from that thread). It injects the result of an RPC call into the view (keeping the map agnostic of how the view displays that data), and the view will create a popup whenever there is data, and remove the popup whenever there is no data. The thread has further explanation of most of this code.

EventMap:

<Injectors target="{PopupParentView}">
    <PropertyInjector destinationKey="rpcData" 
                      source="{FooManager}" sourceKey="rpcData" />
 </Injectors>

PopupParentView:
...

private var popup : UIComponent;

private var rpcData : Object;

private function onPreinitialize( event : Event ) : void {
    BindingUtils.bindSetter(rpcDataChanged, this, "rpcData");
}

private function rpcDataChanged( value : Object ) : void {
    invalidateProperties();
}

override protected function commitProperties( ) : void {
    // two mutually exclusive branches: either the property can be interpreted as "show the popup"
    // and the popup doesn't exist, or we shouldn't show the popup, but it does exist. all other
    if ( rpcData != null && popup == null ) {
        popup = PopUpManager.createPopUp(...);
    } else if ( rpcData == null && popup != null ) {
        // make sure to set the popup property to null
            PopUpManager.removePopUp(popup);
            popup = null;
    }
}
</Script>
...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文