source: EDIS/trunk/java/tracking-ui-core/src/main/flex/gov/va/med/edp/business/responder/XMLResultFormattingResponder.as@ 1227

Last change on this file since 1227 was 1227, checked in by George Lilly, 13 years ago

initial load of EDIS 1.0

File size: 1.4 KB
Line 
1package gov.va.med.edp.business.responder
2{
3 import mx.rpc.Fault;
4 import mx.rpc.IResponder;
5 import mx.rpc.events.FaultEvent;
6 import mx.rpc.events.ResultEvent;
7 import mx.rpc.http.HTTPService;
8
9 /**
10 * Responder that takes a text result and attempts to create an XML object of it. If an error during the XML parse
11 * occurs, fault is called on the decorated responder, otherwise a new ResultEvent is created with result set to the
12 * XML object. This emulates the behavior of setting the resultFormat on HTTPService to "e4x".
13 */
14 public class XMLResultFormattingResponder extends ResponderDecorator implements IResponder
15 {
16 public function XMLResultFormattingResponder(responder: IResponder) {
17 super(responder);
18 }
19
20 public override function result(data:Object):void {
21 var resultEvent:ResultEvent = ResultEvent(data);
22 try {
23 var xml:XML = new XML(String(resultEvent.result));
24 responder.result(new ResultEvent(ResultEvent.RESULT, resultEvent.bubbles, resultEvent.cancelable, xml, resultEvent.token, resultEvent.message));
25 } catch (error:Error) {
26 var fault:Fault = new Fault(HTTPService.ERROR_DECODING, error.message);
27 fault.rootCause = String(resultEvent.result);
28 var faultEvent:FaultEvent = FaultEvent.createEvent(fault);
29 responder.fault(faultEvent);
30 }
31 }
32 }
33}
Note: See TracBrowser for help on using the repository browser.