Posted By

boblinl on 03/01/10


Tagged

architecture parsley


Versions (?)

Session Facade


 / Published in: ActionScript 3
 

  1. public class KeywordEvent extends Event
  2. {
  3. public static const KEYWORD_MESSAGE:String = 'keywordMessage';
  4. public function KeywordEvent()
  5. {
  6. super(KEYWORD_MESSAGE);
  7. }
  8. }
  9.  
  10. [Event( name = "keywordMessage", type="KeywordEvent" )]
  11. [ManagedEvents("keywordMessage")]
  12. public class ImageController extends EventDispatcher
  13. {
  14. public function getKeywordResult():void
  15. {
  16. dispatchEvent(new KeywordEvent());
  17. }
  18. }
  19.  
  20. /**
  21.  * ImageSession class as a facade to encapsulate the complexity of interactions
  22.  * between the business objects participating in the image selection workflow.
  23.  *
  24.  * The Session Facade manages the business objects, and provides a uniform
  25.  * service access layer to clients.
  26.  */
  27. public class ImageSession
  28. {
  29. //remote object
  30. [Inject(id="amfRemote")]
  31. public var remoteObj :RemoteObject;
  32.  
  33. [Inject]
  34. public var keywordViewPM :KeywordViewPresentationModel;
  35.  
  36. [Command(selector="keywordMessage")]
  37. public function getKeywordSearch(event:KeywordEvent):AsyncToken
  38. {
  39. var token:AsyncToken = remoteObj.getKeywordResults(keywordViewPM.searchStr);
  40. return token;
  41. }
  42. }
  43.  
  44. /**
  45.  * KeywordSearchDelegate as a Delegate pattern reduces the coupling between
  46.  * presentation-tier and the system's business services, cached business
  47.  * results into domain models
  48.  */
  49. public class KeywordSearchDelegate implements IDelegate
  50. {
  51. [Inject]
  52. public var imageController:ImageController;
  53.  
  54. [Inject]
  55. public var domainModel :DomainModel;
  56.  
  57. [CommandResult(type="com.picturecabinet.kiosk.event.presentation.KeywordEvent",
  58. selector="keywordMessage")]
  59. public function result(data:ResultEvent):void
  60. {
  61. domainModel.searchResultVO = data.result as SearchResultVO;
  62.  
  63. //search view is programmatically added through 'view injection'
  64. imageController.processSearchViewCreation();
  65. }
  66.  
  67.  
  68. [CommandError(type="com.picturecabinet.kiosk.event.presentation.KeywordEvent",
  69. selector="keywordMessage")]
  70. public function fault(info:FaultEvent):void
  71. {
  72. Alert.show('keyword: ' + info.fault.faultString);
  73. }
  74. }

Report this snippet  

You need to login to post a comment.