4 Replies Latest reply on Apr 16, 2010 2:27 PM by cheftimo

    Questions about FB 4 data-centric development

    cheftimo Level 2

      I have been looking at the new FB4 data-centric development features. So far, I figured out how to bind the results of a call to a service which yields a collection of strongly typed objects – in this case, called products. The problem I am having is that all the tutorials and other things I have found show how to create, call the service and bind the results to a visual component, everything done in design view. This is all cute and a lot of fun, but I would like to understand it fully. So, my questions:

       

      The result of the service call is a collection of objects: how do I refer to that collection to keep using the data – like filtering it from categories in a ComboBox and displaying the filtered results; or binding that collection to other components? I have tried using the debugger to see these things, but no luck.

       

      How can I bring data into Flex and store it – maybe in an Array or ArrayCollection for later use, without having to bind it to a visual component right from the beginning?

       

      All the material I have been able to find is all about doing everything in Design View. Can someone point me to a tutorial or something where I can see how to code all these things in AS/MXML?

       

      I would really appreciate any ideas. Best regards,

       

      Carlos

        • 1. Re: Questions about FB 4 data-centric development
          SpaghettiCoder Level 3

          //Define your call

          ro = new RemoteObject;

          ro.destination = "getDataService";

          ro.getData.addEventListener("result", getDataResultHandler);

           

          //make the call to the server

          ro.getData();

           

          //Handle the result.

          private function getDataResultHandler(event:ResultEvent):void

          {

               myArrayCollection = new ArrayCollection(event.result as Array);

          }

           

           

          So now your data sites in myArrayCollection, and you can do whatever you like with it.

          • 2. Re: Questions about FB 4 data-centric development
            cheftimo Level 2

            Hi SpaghettiCoder,

             

            I appreciate your reply. What you suggest is certainly correct, but what I am looking for is something else, so let me elaborate, in case you or someone else wants to contribute other ideas.

             

            In a recent catalog project I did with FB 3, I created a service – an MXML custom component based on UIComponent. That RemoteObject service was only written once, but was called from four other components to get different datasets from different database tables. This works very well.

             

            When I saw that FB 4 can create a service, I thought that would be a good way to save time – not having to write a service component, but just introspecting a CFC and creating the service in seconds. The idea would be to capture the data generated by calls to this service and save it in collections for later use. My service was an MXML file of 4950 bytes; the service created by FB 4 was in two files totaling 5500 bytes – so far , so good.

             

            But now, looking a little deeper, I find that the value object created by FB 4 takes three AS files, total size 50800 bytes. My own value object for the same thing is one 860 byte AS file. Plus, so far, I have not been able to find out how to capture that data to save it – or even how to see it in the debugger.

             

            <s:Remoteobject> is available, so I guess I will keep doing these things as before, unless somebody points out something I have been missing.

             

            It pisses me off a little to see that all the articles – from Adobe & others – available out there are all about how cool this “data-centric development” is, but they don’t really contain any meaningful documentation. It’s all designed to dazzle you with BS, but there is no real information. For example, shouldn’t these articles point out – to the prospective suckees – that somebody, at some point is going to have to write a goof CFC, or PHP template, or whatever?

             

            This reminds me a lot of when Macromedia released Dreamweaver UltraDev – now, nobody had to even know ColdFusion existed, but a short-order cook could all of a sudden create CF applications “without writing one single line of code” (Anybody aver see the code UltraDev generated?). This data-centric BS is the same thing.

             

            I think I will be making my FB 4 trial a full license. But it ain’t gonna be because of its data-centricism; it will be for the new easier styling and skinning – that part is very good.

             

            Adobe, are you sure there isn’t a typo in there somewhere? Sometimes it feels like your “Developer Center” should really be called “Marketing  Center”.

             

            Best regards to all,

             

            Carlos

            • 3. Re: Questions about FB 4 data-centric development
              CrazyMerlin

              I find the problem with the new data-centric aspects is that they are not aimed at seasoned developers who want to get at the core of what is going on. They are aimed at RAD developers and script-kiddies.

               

              I am trying to consume a WSDL for AmazonS3 using the data-centric features and have been hitting brick wall after brick wall, to the point where it has been a complete waste of time and I could have manually coded the service.

               

              I searched online for help with using the data-centric aspects and also found nothing other than binding data to a UI component...but what about authentication? Flash Player now no longer allows a RESTful connection to the service because of all the disallowed header responses. And using GET is no good at all because Flash Player strips all the headers before it even makes the request.

               

              I am really looking to get my hands dirty with SOAP and Flex 4 but cannot find anything more than kids stuff in ADC.

               

              So now after a full day or bad blog posts, I am going to have to turn to PHP and build a proxy.

               

              Regards,

              ChefPaul

              1 person found this helpful
              • 4. Re: Questions about FB 4 data-centric development
                cheftimo Level 2

                I played with this thing some more, but was never able to find out how to access the data in the service created by FB 4, so I decided to do a test: I created a second version of the little project referred to in my original post, with one difference: instead of creating the service and binding the result to a tile list by dragging it in design view as directed in the “data-centric” sample app, I created the service as a custom component extending the mx:UIComponent – everything else stayed the same as before.

                 

                I was not surprised to find the following:

                 

                the “data-centric” debug SWF size = 114,953 bytes;

                the custom component debug SWF size = 93,113 bytes;

                the “data-centric” release SWF = 65,503 bytes;

                the custom component release SWF = 54,679 bytes.

                 

                So, the data-centric SWFs end up 20 – 23% bigger than the ones fromm the MXML custom component. Also, now I have the data in an ArrayCollection and can use it in other places any time I need it.

                 

                So much for this cool and dazzling data-centric BS.

                 

                If anyone thinks I am missing something, please let me know.

                 

                Salud,

                 

                Carlos