/ Published in: ActionScript 3
Expand |
Embed | Plain Text
public class KeywordEvent extends Event { public static const KEYWORD_MESSAGE:String = 'keywordMessage'; public function KeywordEvent() { super(KEYWORD_MESSAGE); } } [Event( name = "keywordMessage", type="KeywordEvent" )] [ManagedEvents("keywordMessage")] public class ImageController extends EventDispatcher { public function getKeywordResult():void { dispatchEvent(new KeywordEvent()); } } /** * ImageSession class as a facade to encapsulate the complexity of interactions * between the business objects participating in the image selection workflow. * * The Session Facade manages the business objects, and provides a uniform * service access layer to clients. */ public class ImageSession { //remote object [Inject(id="amfRemote")] public var remoteObj :RemoteObject; [Inject] public var keywordViewPM :KeywordViewPresentationModel; [Command(selector="keywordMessage")] public function getKeywordSearch(event:KeywordEvent):AsyncToken { var token:AsyncToken = remoteObj.getKeywordResults(keywordViewPM.searchStr); return token; } } /** * KeywordSearchDelegate as a Delegate pattern reduces the coupling between * presentation-tier and the system's business services, cached business * results into domain models */ public class KeywordSearchDelegate implements IDelegate { [Inject] public var imageController:ImageController; [Inject] public var domainModel :DomainModel; [CommandResult(type="com.picturecabinet.kiosk.event.presentation.KeywordEvent", selector="keywordMessage")] public function result(data:ResultEvent):void { domainModel.searchResultVO = data.result as SearchResultVO; //search view is programmatically added through 'view injection' imageController.processSearchViewCreation(); } [CommandError(type="com.picturecabinet.kiosk.event.presentation.KeywordEvent", selector="keywordMessage")] public function fault(info:FaultEvent):void { Alert.show('keyword: ' + info.fault.faultString); } }
You need to login to post a comment.
