source: ComponentRegistry/branches/jeaferversion/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/services/CommentInfoService.as @ 1636

Last change on this file since 1636 was 1636, checked in by jeafer, 13 years ago

Jean-Charles branch ComponentBrowserGui commit1,
Changes regarding comment on the ComponentBrowserGui.

Starting to implement classes for Comment visualisation
CommentInfoPage? and CommentXmlPanel?
CommentService? (List and info)
Comment and CommentDescription?
Update on InfoPage?

File size: 1.9 KB
Line 
1package clarin.cmdi.componentregistry.services {
2       
3        import clarin.cmdi.componentregistry.common.Comment;
4        import clarin.cmdi.componentregistry.common.CommentMD;
5        import clarin.cmdi.componentregistry.common.CommentDescription;
6       
7        import com.adobe.net.URI;
8       
9        import flash.events.Event;
10        import flash.events.EventDispatcher;
11       
12        import mx.controls.Alert;
13        import mx.messaging.messages.HTTPRequestMessage;
14        import mx.rpc.AsyncToken;
15        import mx.rpc.Responder;
16        import mx.rpc.events.FaultEvent;
17        import mx.rpc.events.ResultEvent;
18        import mx.rpc.http.HTTPService;
19        import mx.utils.StringUtil;
20       
21       
22        [Event(name="CommentLoaded", type="flash.events.Event")]
23        public class CommentInfoService extends EventDispatcher {
24                public static const COMMENT_LOADED:String = "CommentLoaded";
25               
26                private var service:HTTPService;
27               
28                [Bindable]
29                public var comment:Comment;
30
31                public function CommentInfoService() {
32                        this.service = new HTTPService();
33                        this.service.method = HTTPRequestMessage.GET_METHOD;
34                        this.service.resultFormat = HTTPService.RESULT_FORMAT_E4X;
35                }
36                public function load(item:CommentDescription):void {
37                        comment = new Comment();
38                        comment.description = item;
39                        var url:URI = new URI(item.dataUrl);
40                        service.url = url.toString();
41                        var token:AsyncToken = this.service.send();
42                        token.addResponder(new Responder(result, fault));
43                }
44               
45                private function result(resultEvent:ResultEvent):void {
46                        var resultXml:XML = resultEvent.result as XML;
47                        var metaData:CommentMD = new CommentMD();
48                        metaData.name = resultXml.CMD_Comment.@name;
49                        metaData.xml = resultXml;
50                        comment.commentMD = metaData;
51                        dispatchEvent(new Event(COMMENT_LOADED));
52                }
53               
54                public function fault(faultEvent:FaultEvent):void {
55                        var errorMessage:String = StringUtil.substitute("Error in {0}: {1} - {2}", this, faultEvent.fault.faultString, faultEvent.fault.faultDetail);
56                        Alert.show(errorMessage);
57                }
58        }
59}
Note: See TracBrowser for help on using the repository browser.