Announcement Announcement Module
Collapse
No announcement yet.
Best common design pattern for a new project available? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Best common design pattern for a new project available?

    Hello all,
    so i follow the suggestion of 666shooter ;-) and i am asking the community if there is a recommended way to start a new AIR Desktop project using the MVC pattern. I am planing a rich desktop application which has a database-layer for connecting to a remote database.

    Is there a very very simple example available which shows how to organize the project and make usage of MVC with Spring Actionscript 2 ? When i read the documentation then there is the puremvc already included?

  • #2
    Hi there!
    First of all, I recommend you to see examples on http://springactionscript.org/samples.html.
    The structure of a project is simple view-model application.
    Unfortunately I don't have any expirience in using pureMVC, but for organize data transering in my apps I using Mate Framework. Now SpringAS2 and As3commons replaced them all.
    Using AIR desktop app to connect to remote database - is not good idea (i don't how it could be possible?). Better way is write a server-side on java, using Spring Flex Integration, and connect your client to this server through RemoteObject.

    Comment


    • #3
      Hi grammer, thanks for your answer.
      I want to use REST calls to communicate AIR with the Backend-Service, so that i can develop later a native iOS and Android App.

      Comment


      • #4
        sorry...

        Hi,

        sorry for the late reply...
        Spring Actionscript doesn't offer a complete MVC/MVP implementation to use since we decided that we don't want to impose any kind of patterns on people's projects.

        It is however very easy to create your own implementation using the as3commons-async project (http://www.as3commons.org/as3-common...roduction.html and http://www.as3commons.org/as3-common...roduction.html). A lot of people use presentationmodels in Flex applications, so a common implementation would have views injected with a presentationmodel using SpringAS and then have the presentationmodel use services to connect to a backend.
        A service is nothing more than a facade for a couple of, for instance, RemoteObject calls, which can be easily implemented using the RemoteObjectService in as3commons-asyncFlex.
        So, as a short example, this is what a service call would basically look like:

        Code:
        var operation:IOperation = serviceInstance.someRemoteCall();
        operation.addCompleteListener(completeHandler);
        operation.addErrorListener(errorHandler);
        
        function completeHandler(event:OperationEvent):void {
          //so something with event.result
        }
        function errorHandler(event:OperationEvent):void {
          //so something with event.error
        }
        The service method someRemoteCall() would look a little like this:
        Code:
        function someRemoteCall():IOperation {
          return service.call("someRemoteCall");
        }
        where service is a RemoteObjectService instance, which can be instantiated like this:

        Code:
        var service:RemoteObjectService = new RemoteObjectService(new RemoteObject());
        Obviously this is greatly simplified, but this is the gist of it.
        Naturally you'd use the SpringAS container to configure all of these objects, but I hope this will set you on your way a little.

        If you have any questions or problems, feel free to ask.

        cheers,

        Roland

        Comment


        • #5
          By the way, I wonder again about this RemoteObject, how it can be used.
          I have a java server side, with Spring Flex Integration + Spring Security, and use spring-beans as a destinations for my RemoteObject. So I have one RemoteObject, with ChannelSet what is used for loggin (channelSet.login method). And so, I use this one RO for every service in client, but before call method I must to set correct destination, like this:
          Code:
          	public class RemoteModelService extends RemoteObjectService implements IModelService {
          		private static const DESTINATION:String = "modelManager";
          		
          		public function RemoteModelService(remoteObject:RemoteObject=null) {
          			super(remoteObject);
          		}
          		
          		public function getModel():IOperation {
          			remoteObject.destination = DESTINATION;
          			return call('getModel'); 
          		}
          	}
          Maybe it's a better way to use different instances of RemoteObjects for every DAO on server, with same channelSet?

          Comment

          Working...
          X