4 Replies Latest reply on Mar 2, 2010 9:39 AM by JohnMerlino

    http data service bug

    JohnMerlino Level 1

      Hey all,

       

      For a month now, all I have been trying to do is expose xml data in Flash Builder 4 Beta using the HTTP Service type. I found this tutorial from adobe.com that uses Coldfusion:  http://www.adobe.com/devnet/flashcatalyst/articles/building_datacentric_app_flashcast_flas hbuilder_03.html. It says that you could achieve the same effect with HTTP Service, so I followed it where applicable.However, when I run the Flash Builder application, I'm expecting to see 25 records from users table of my database in a list component, and all I see is 25 of this: [object User].


      What I did:

      1) Connect to data service (Http)

      2) Entered a url of xml data, method GET, operation of getAllItems

      4) users as service name (services.users as service package)

      5) test operation (checked authentication required) and clicked test, which showed the xml data

      6) Configure return type, selected User as root (not users), checked "is Array?" option

      7) Then selected the list component, clicked bind to data, checked "New Service Call", and for bind_to_field I left it at the default value, which is just one of the columns in the users table of my database (I tried swithing the value to another column as well, still getting the same results).

       

       

      The following is the relevant stuff that was generated:

       

       

           protected function list_creationCompleteHandler(event:FlexEvent):void
           {
                getAllItemsResult.token = users.getAllItems();
           }


           <fx:Declarations>
                <s:CallResponder id="getAllItemsResult"/>
                <users:Users id="users" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
           </fx:Declarations>

           <s:List skinClass="components.DataList3" x="65" y="96" change="list_changeHandler()" id="list" creationComplete="list_creationCompleteHandler(event)" dataProvider="{getAllItemsResult.lastResult}" labelField="completed_first_experience_at">
           </s:List>

       

      It's not showing records from the database (via the xml) but rather just showing: [object User]. I posted this in numerous forums and have yet to get a response. I also looked at the documentation from adobe and I followed all instructions on it. So either it's a bug or the documentation is inaccurate. It should not be this difficult just to expose xml data in a list. Thanks for any response.

        • 1. Re: http data service bug
          JohnMerlino Level 1

          nevermind. Beware flex wants xml a certain way.

          • 2. Re: http data service bug
            hneelu Adobe Employee

            Hi John

             

            When you do Configure Return Type, select the string/string array that you want to display.

            Example user->name or user->address and not object 'user'.

            After this step, do a bind to data to a list and it would work.

             

             

            Alternately, in the code you can do

            dataProvider="{getAllItemsResult.lastResult.name}"

            Hope this helps.

            • 3. Re: http data service bug
              Flex harUI Adobe Employee

              Add a button that traces out:

               

              ObjectUtil.toString(list.dataProvider[0]);

              • 4. Re: http data service bug
                JohnMerlino Level 1

                It seemed that the problem was in the xml and not in flash builder, because I removed type attribute from xml and it worked. When I run the flash builder application,  it properly displays the data in the list state. However, when I click on one of items in list state to invoke the detail state, I'm expecting the xml associated with the row I clicked in to populate. However, it doesn't the first time. After I click on one item that fails, then I click on the item in the row below it, and then it populates the corresponding data correctly in the detail view. Now it doesn't matter which row I click in the first time. The first click no data displays in the detail view. Only on the second click will it display. I was following the adobe.com tutorial above. Here's what I have:

                 

                 

                        <![CDATA[
                            import mx.events.FlexEvent;
                            import mx.controls.Alert;
                            protected function textInput_enterHandler():void
                            {
                                currentState='List';
                                getAllItemsResult2.token = users.getAllItems(search.text);
                            }

                 

                            protected function list_changeHandler():void
                            {
                                currentState='Detail';

                 

                            }

                 


                            protected function button_clickHandler():void
                            {
                                currentState='List';
                            }

                 


                            protected function button_clickHandler_1():void
                            {
                                currentState='Search';
                            }

                 

                 

                 

                        ]]>

                 

                    <fx:Declarations>
                        <s:CallResponder id="getAllItemsResult2"/>
                        <users:Users id="users" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
                        <valueObjects:Student fx:id="student"/>
                    </fx:Declarations>
                    <fx:Binding source="dataGrid.selectedItem as Student" destination="student"/>

                 

                                            <mx:Form includeIn="Detail" x="14" y="278">
                                                <mx:FormItem label="Date_of_birth">
                                                    <s:TextInput id="date_of_birthTextInput" text="@{student.date_of_birth}"/>
                                                </mx:FormItem>
                                                <mx:FormItem label="Failed_on">
                                                    <s:TextInput id="failed_onTextInput" text="@{student.failed_on}"/>
                                                </mx:FormItem>
                                                <mx:FormItem label="Site_id">
                                                    <s:TextInput id="site_idTextInput" text="@{student.site_id}"/>
                                                </mx:FormItem>
                                            </mx:Form>

                 

                                <mx:DataGrid  x="10" y="10" width="271" height="340" id="dataGrid" dataProvider="{getAllItemsResult2.lastResult}" change="list_changeHandler()" >

                 

                            <s:TextInput skinClass="components.TextInput1" text="Search" x="112" y="53" enter="textInput_enterHandler()" id="search"/>