Question

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.

Was it helpful?

Solution

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>
...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top