Ignore:
Timestamp:
03/17/10 13:03:11 (14 years ago)
Author:
patdui
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/IsocatService.as

    r224 r238  
    11package clarin.cmdi.componentregistry.services {
    22        import com.adobe.net.URI;
    3        
     3
    44        import flash.events.ErrorEvent;
    55        import flash.events.EventDispatcher;
    6        
     6
    77        import mx.controls.Alert;
    88        import mx.managers.CursorManager;
    99        import mx.utils.StringUtil;
    10        
     10
    1111        import org.httpclient.HttpClient;
    1212        import org.httpclient.events.HttpDataEvent;
     
    2525
    2626                public function IsocatService() {
    27                         service = new HttpClient();
    28                         service.listener.onComplete = handleResult;
    29                         service.listener.onError = handleError;
    30                         service.listener.onData = handleData;
    3127                }
    3228
    3329                public function load(keyword:String):void {
    3430                        if (keyword) {
     31                                createClient();
    3532                                CursorManager.setBusyCursor();
    3633                                var uri:URI = new URI(Config.instance.isocatSearchUrl);
     
    4441                }
    4542
    46                 public function handleData(event:HttpDataEvent):void {
     43                public function close():void {
     44                        if (service) {
     45                                service.close();
     46                        }
     47                        CursorManager.removeBusyCursor();
     48                }
     49
     50                private function createClient():void {
     51                        service = new HttpClient();
     52                        service.listener.onComplete = handleResult;
     53                        service.listener.onError = handleError;
     54                        service.listener.onData = handleData;
     55                }
     56
     57                private function handleData(event:HttpDataEvent):void {
    4758                        var data:XML = new XML(event.bytes);
    4859                        searchResults = data.dcif::dataCategory;
     
    5869                }
    5970
    60                 public function handleError(faultEvent:ErrorEvent):void {
     71                private function handleError(faultEvent:ErrorEvent):void {
    6172                        CursorManager.removeBusyCursor();
    6273                        var errorMessage:String = StringUtil.substitute("Error in {0}: {1}", this, faultEvent.text);
    63                     Alert.show(errorMessage);
     74                        Alert.show(errorMessage);
    6475                }
    6576
Note: See TracChangeset for help on using the changeset viewer.