New Proxy Component in UcompOS SDK: UcompOSAlertProxy
This morning, I have just added a new Proxy Component to the UcompOS SDK: UcompOSAlertProxy that is available in version 0.2.2 and later of the UcompOS Developers Package.
UcompOSAlertProxy provides a way to create a modal dialogue on the UcompOS Portal via an implementation of the Flex Alert control.
Previously, I had made this possible with the createAlert(); method of the SDK class UcompOSGlobalManagerProxy.
The inefficiency with this is that UcompOSGlobalManagerProxy is a Singleton class (along with UcompOSDockProxy, UcompOSMenuBarProxy, and UcompOSStyleProxy). So one instance of UcompOSGlobalManagerProxy would handle the event dispatching for all Alert dialogues created with its createAlert(); method.
So handling events dispatched by Alerts created with UcompOSGlobalManagerProxy’s createAlert(); method required extra handling and actually provided risks of gaps in data integrity and continuity.
I have removed the createAlert(); from UcompOSGlobalManagerProxy and replaced the functionality with the simpleAlert(); and confirmAlert(); methods of the UcompOSAlertProxy class.
The simpleAlert(); method launches a simple Alert with a single control button that will default with a label of “OK”.
The signature of simpleAlert(); is as follows:
public function simpleAlert(title:String, message:String, okLabel:String="OK"):void
You have the ability to customize the label on the single button presented on the Alert control.
The signature of confirm(); is as follows:
public function confirm(title:String, message:String, okLabel:String = null, cancelLabel:String = null, defaultButton:String="OK"):void
You can specify the labels to be used on both the OK and Cancal buttons and you can articulate which should be the default button.
When the user takes action and clicks a button on the Alert dialogue, an instance of SDKEvent is dispatched by the UcompOSAlertProxy instance of type UcompOSAlertProxy.ALERT_SUBMIT.
The SDKEvent instance’s data property will have a detail property of type String which will have a value of UcompOSAlertProxy.OK or UcompOSAlertProxy.CANCEL.
Let’s look at a very simple example with the aid of some code:
private function fileExists(file:String):void { var a:UcompOSAlertProxy = new UcompOSAlertProxy(); a.data = file; a.addEventListener(UcompOSAlertProxy.ALERT_SUBMIT,fileExists_handler); a.confirm("A file named "+file+" exists in the target location. Do you wish to overwrite it?","Yes","No",UcompOSAlertProxy.CANCEL); } private function fileExists_handler(event:SDKEvent):void { var a:UcompOSAlertProxy = event.proxyComponent as UcompOSAlertProxy; if(event.data.detail==UcompOSAlertProxy.OK) { trace("Overwrite file "+a.data); } }
