/
ContactDelegate.as
77 lines (65 loc) · 1.98 KB
/
ContactDelegate.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package com.af.cep.model.business
{
import mx.rpc.IResponder;
import mx.rpc.events.FaultEvent;
import com.adobe.cairngorm.business.Responder;
import com.adobe.cairngorm.business.ServiceLocator;
import com.af.cep.vo.ContactVO;
import mx.controls.Alert;
import flash.utils.setTimeout;
import mx.rpc.AsyncToken;
import mx.rpc.events.ResultEvent;
public class ContactDelegate
{
private var responder : IResponder;
private var service : Object;
public function ContactDelegate( responder : IResponder )
{
this.service = ServiceLocator.getInstance().getService( "contactService" );
this.responder = responder;
}
public function addContact( contactVO : ContactVO ): void
{
// Use with IResponder
//var call:AsyncToken = service.insertContact(contactVO);
//call.addResponder( responder );
//for demo purpose: simulate remote service result
setTimeout( addcontactResult, 1000, contactVO );
}
public function updateContact( contactVO : ContactVO ): void
{
// Use with IResponder
//var call:AsyncToken = service.updateContact(contactVO);
//call.addResponder( responder );
//for demo purpose: simulate remote service result
setTimeout( addcontactResult, 1000, contactVO );
}
public function deleteContact( contactVO : ContactVO ): void
{
// Use with IResponder
//var call:AsyncToken = service.deleteContact(contactVO.objectIdentifier);
//call.addResponder( responder );
//for demo purpose: simulate remote service result
setTimeout( addcontactResult, 1000, contactVO );
}
public function getContacts(): void
{
// Use with IResponder
//var call:AsyncToken = service.getContacts();
//call.addResponder( responder );
//for demo purpose: simulate remote service result
setTimeout( addcontactResult, 1000);
}
private function addcontactResult( contactVO : ContactVO ): void
{
if( 1 )
{
responder.result( contactVO );
}
else
{
responder.fault(FaultEvent);
}
}
}
}