/
DeleteContactCommand.as
45 lines (36 loc) · 1.36 KB
/
DeleteContactCommand.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
package com.af.cep.commands
{
import mx.rpc.events.ResultEvent;
import mx.rpc.IResponder;
import mx.collections.ArrayCollection;
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.DeleteContactEvent;
import com.af.cep.model.ModelLocator;
import com.af.cep.vo.ContactVO;
import mx.controls.Alert;
public class DeleteContactCommand 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 deleteContactEvent : DeleteContactEvent = DeleteContactEvent( event );
delegate.deleteContact( deleteContactEvent.contactVO );
}
public function result( data:Object ) : void
{
var event:ResultEvent = data as ResultEvent;
model.addcontact.isPending = false;
(model.contactDG.dataProvider as ArrayCollection).removeItemAt(model.contactDG.selectedIndex);
}
public function fault( info:Object ) : void
{
model.addcontact.statusMessage = "Could not send contact information to the server.";
model.addcontact.isPending = false;
}
}
}