Configuration Guide for Siebel Offline Client for Life Sciences > Extending the Business Functions > Process of Defining Business Services >

Adding a Business Service


This task is a step in Process of Defining Business Services. Create a new MyServices.as business service file, and configure the ServiceManager.as file so that it recognizes the newly created MyServices.as file as a business service file.

To add and configure a business service

  1. Create a new file called MyServices.as, and save it in the following directory:

    CONFIG_PROJECTS\externalservices\src\services

  2. 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);

    }

    }

    }

    }

  3. Save the MyServices.as file.
  4. Open the ServiceManager.as file in the following directory:

    CONFIG_PROJECTS\externalservices\src\services

  5. Add the following line to the m_arrServiceClasses:

    "MyServices",

  6. Define a ClassFactory by adding the following line:

    private var m_cfMyServices:ClassFactory = new ClassFactory(MyServices);

    NOTE:  A ClassFactory is a factory object that Adobe Flex uses to generate instances of another class, each with identical properties.

  7. Add the following line to the GetService() function:

    case "MyServices":

    cf = m_cfMyServices;

    break;

  8. Save the ServiceManager.as file.
Configuration Guide for Siebel Offline Client for Life Sciences Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Legal Notices.