/
AddContactCommand.as
43 lines (34 loc) · 1.23 KB
/
AddContactCommand.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
package com.af.cep.commands
{
import mx.rpc.events.ResultEvent;
import mx.rpc.IResponder;
import com.adobe.cairngorm.business.Responder;
import com.adobe.cairngorm.commands.Command;
import com.adobe.cairngorm.control.CairngormEvent;
import com.af.cep.model.business.ContactDelegate;
import com.af.cep.commands.events.AddContactEvent;
import com.af.cep.model.ModelLocator;
import com.af.cep.vo.ContactVO;
public class AddContactCommand implements Command, IResponder
{
private var model : ModelLocator = ModelLocator.getInstance();
public function execute( event : CairngormEvent ) : void
{
model.addcontact.isPending = true;
var delegate : ContactDelegate = new ContactDelegate( this );
var addcontactEvent : AddContactEvent = AddContactEvent( event );
delegate.addContact( addcontactEvent.contactVO );
}
public function result( data:Object ) : void
{
var event:ResultEvent = data as ResultEvent;
model.addcontact.isPending = false;
model.contacts.addItem(model.addcontact.contactVO);
}
public function fault( info:Object ) : void
{
model.addcontact.statusMessage = "Could not send contact information to the server.";
model.addcontact.isPending = false;
}
}
}