Cut and paste the following code into the MyServices.as file:
package services
{
import businessservices.IService;
import businessservices.ServiceBase;
// import mx.collections.XMLListCollection;
import sharedobjs.GlobalObjs;
//import sharedutils.ExprParser;
//import sharedutils.StringHelper;
import mx.controls.Alert;
import mx.events.CloseEvent;
import sharedobjs.UIEvent;
public class MyServices extends ServiceBase implements IService
{
private var m_arrApplets:Array;
//
// Define your business service methods here
//
public function LSValidations():void
{
m_arrMethods = new Array("MyDelete");
}
//
// Function to invoke a method
//
public function InvokeMethod(func:String, param:Object):Object
{
try
{
var result:Object = new Object();
result.status = false;
result.errMsg = func;
if (func == "MyDelete")
{
result = MyDelete();
}
}
catch(error:Error)
{
GlobalObjs.AppMsgLog.logMessage(error, "MyServices::InvokeMethod "
+ error.message);
}
return result;
}
//
// Function to raise an alert to get user confirmations
//
private function MyDelete(data:Object = null):Object
{
try
{
var result:Object = new Object;
result.status = true;
result.errMsg = "MyDelete";
Alert.show("You are about to delete a record. Click OK to proceed or
Cancel to abort.", "Delete Confirmation",Alert.OK | Alert.CANCEL,
null, alertListener, null, Alert.CANCEL);
}
catch(error:Error)
{
GlobalObjs.AppMsgLog.logMessage(error, "MyDelete " + error.message);
result.status = false;
}
return result;
}
//
// Function to handle CloseEvent from the alert and raise a DELETEDATA event
upon positive confirmation from users
//
private function alertListener(eventObj:CloseEvent):void
{
if (eventObj.detail == Alert.OK)
{
var evt:UIEvent = new UIEvent(UIEvent.DELETEDATA);
evt.directListener = this.applet;
evt.state = "DEFAULT";
GlobalObjs.Notification.Notify(evt);
}
}
}
}