{"id":13744926,"url":"https://github.com/MattesGroeger/as3-parsley-example","last_synced_at":"2025-05-09T04:31:19.994Z","repository":{"id":1152771,"uuid":"1037748","full_name":"MattesGroeger/as3-parsley-example","owner":"MattesGroeger","description":"Example that demonstrates short living Commands configured via ActionScript.","archived":false,"fork":false,"pushed_at":"2010-10-30T22:13:19.000Z","size":553,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-08-04T05:05:24.387Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"ActionScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MattesGroeger.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-10-30T16:43:10.000Z","updated_at":"2015-09-25T06:15:27.000Z","dependencies_parsed_at":"2022-08-16T12:15:29.810Z","dependency_job_id":null,"html_url":"https://github.com/MattesGroeger/as3-parsley-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MattesGroeger%2Fas3-parsley-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MattesGroeger%2Fas3-parsley-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MattesGroeger%2Fas3-parsley-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MattesGroeger%2Fas3-parsley-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MattesGroeger","download_url":"https://codeload.github.com/MattesGroeger/as3-parsley-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224811318,"owners_count":17373946,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T05:01:18.603Z","updated_at":"2024-11-15T16:32:11.252Z","avatar_url":"https://github.com/MattesGroeger.png","language":"ActionScript","funding_links":[],"categories":["Unsorted"],"sub_categories":["Other API"],"readme":"Parsley Commands Example\n========================\n\nThis example shows how to use Parsley with pure [ActionScript configuration](http://www.spicefactory.org/parsley/docs/2.3/manual/config.php#as3) and [Short-lived Command Objects](http://www.spicefactory.org/parsley/docs/2.3/manual/messaging.php#command_objects). \n\nParsley is an advanced open source application framework. Download and documentation can be [found here](http://www.spicefactory.org/parsley/).\n\nAbout the example\n-----------------\n\nThis mvc example demonstrates login and logout functionality over an faked `SessionService` (see below under \"Fake Service\"). \n\nThe login only works with the following login data:\n\n\tuser name: \tadmin\n\tpassword:\ttest\n\nThe credentials are validated within the Service. In case the credentials are wrong, the view displays an `Alert` pop up. If they are correct an result page is displayed and you can logout again. Login and Logout is controlled by short-lived command objects.\n\nShort-lived Command Objects\n---------------------------\n\nSince Parsley 2.2 the framework supports commands. Part of this implementation is the support of short-lived command objects. That are commands that are only created when a specific message has been dispatched. Afterwards the command is immediately removed from the context. For further information [read on here](http://www.spicefactory.org/parsley/docs/2.3/manual/messaging.php#command_objects).\n\nUntil now an easy configuration is only available via `MXML` or `XML` configuration, by using the `DynamicCommand` tag. But by using `XML` you loose the strong type check of the compiler. And the `MXML` approach is not possible in pure ActionScript applications. \n\nIf you want to use this feature with pure ActionScript configurations, you have to use the [Configuration DSL](http://www.spicefactory.org/parsley/docs/2.3/manual/config.php#dsl). Because this configuration is not well documented and a bit more complicated, I encapsulated this feature within a `CommandMap` class. So you can easily reuse this class if you need this feature.\n\n**Important:** In order to use the `CommandMap` you have to build the Context by using the Configuration DSL, like in the following example. The `MainConfig` is the class where all the definitions for the context have to be defined.\n\n\tvar contextBuilder:ContextBuilder = ContextBuilder.newSetup()\n    \t.viewRoot(this)\n\t\t.newBuilder();\n\t\t\n\tvar commandMap:CommandMap = new CommandMap(contextBuilder);\n\tcommandMap.register(LoginCommand, LoginRequest);\n\tcommandMap.register(LogoutCommand, LogoutRequest);\n\t\t\t\n\tcontextBuilder.config(ActionScriptConfig.forClass(MainConfig));\n\tcontextBuilder.build();\n\nThe first step is to create the `ContextBuilder` which then has to be passed into the `CommandMap` instance. Afterwards you can register all your command mappings. The last step is to build the context.\n\nBut why does the example uses Flex then?\n----------------------------------------\n\nFlex has been used to provide an fast and simple output. Special features that were used are [explicit component wiring for Flex](http://www.spicefactory.org/parsley/docs/2.3/manual/view.php#config_explicit) to register `MXML` views automatically in the context. The actual command mapping which is demonstrated in the example can be used in pure ActionScript projects.\n\nFake Service\n------------\n\nThere are two classes that were necessary for the asynchronous fake service implementation: `FakeServiceRequest` and `ServiceRequestCommandFactory`. The first one just implements the delay of one second. The second one is used by Parsley for the reflection on the return type of the execute method in the commands. \n\nThe factory has to be registered in Parsley:\n\n\tvar settings:MessageSettings = \n\t\tGlobalFactoryRegistry.instance.messageSettings;\n\tsettings.commandFactories.addCommandFactory(\n\t\tServiceRequest, new ServiceRequestCommandFactory());\n\nMore information can be found here [in the Parsley documentation](http://www.spicefactory.org/parsley/docs/2.3/manual/extensions.php#commands).\n\nLimits\n------\n\nBecause the mapping takes place in the construction phase of the context it is not possible to un-map these commands later at runtime. The only way to remove the mapping would be to destroy the context where they are registered in.\n\nContact\n-------\nBlog: [blog.mattes-groeger.de](http://blog.mattes-groeger.de/)  \nTwitter: [@MattesGroeger](https://twitter.com/MattesGroeger)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMattesGroeger%2Fas3-parsley-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMattesGroeger%2Fas3-parsley-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMattesGroeger%2Fas3-parsley-example/lists"}