2 Replies Latest reply on Feb 24, 2010 8:10 AM by JohnMerlino

    connect to data/server

    JohnMerlino Level 1

      Hey all,

       

      I follow this tutorial: http://www.adobe.com/devnet/flashcatalyst/articles/building_datacentric_app_flashcast_flas hbuilder_03.html

      Whereas he's using Coldfusion, I am using Ruby on Rails so I choose HTTP from Select Service Type.
      When I bind the data to the list, and select new service call, the values are student_requests for Service and index(search : Object): Student_requests for Operation. I click ok and it generates this code:

                  protected function list1_creationCompleteHandler(event:FlexEvent):void
                  {
                      indexResult.token = student_requests.index(/*Enter value(s) for */ search);
                  }

       

      Then I run the application and  rather than returning the data set, it returns: [object Student_requests]

       

      Note that when I went to configure the return type and entered a complete URL:

      http://localhost:3000/student_requests.xml

       

      It gave me error message and said "The response is not a valid XML"

      So I pasted the xml:

      <student_requests type="array">

      <student_request>
      <created_at type="datetime">2010-02-22T19:49:41Z</created_at>
      <creator_id type="integer" nil="true"/>
      <id type="integer">2</id>
      </student_request>
      </student_requests>

      This works, but as I mentioned, when I run the application, it just returns:  [object Student_requests]

       

      The xml looks fine to me. I'm not sure why it's not displaying it in the form. Does anyone have any suggestions? Thanks.

        • 1. Re: connect to data/server
          saisri2k2 Level 4

          for the server call you are making if it is http call

           

          HttpService http = new htt ....

           

          put http.resultFormat = 'e4x'

          • 2. Re: connect to data/server
            JohnMerlino Level 1

            Can I specify e4x when using CallResponder?

            This is what I have:

             

            <fx:Script>
                    <![CDATA[
                        import mx.events.FlexEvent;
                        import com.adobe.serializers.utility.TypeUtility;
                        import mx.controls.Alert;
                        protected function textInput_enterHandler():void
                        {
                            currentState='List';
                        }

             

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

             


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

             


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

             


                        protected function list1_creationCompleteHandler(event:FlexEvent):void
                        {
                            indexResult.token = student_requests.index(/*Enter value(s) for */ search);
                        }

             

                    ]]>

             

                </fx:Script>
                <s:states>
                    <s:State name="Detail"/>
                    <s:State name="List"/>
                    <s:State name="Search"/>
                </s:states>
                <fx:Declarations>
                    <s:CallResponder id="indexResult"/>
                    <student_requests:Student_requests id="student_requests" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>

                </fx:Declarations>

             

                <fx:DesignLayer d:id="49" ai:objID="644a1270" d:userLabel="LeftPanel" visible.Search="false" id="designlayer2">
                        <s:Group id="group2" d:id="50" flm:knockout="false" ai:objID="644a1670" d:userLabel="Background" x="57" y="84">
                            <s:Rect height="358" ai:objID="644a17f0" width="289" x="1" y="1">
                                <s:stroke>
                                    <s:SolidColorStroke caps="none" color="0x5C5C5C" joints="miter" miterLimit="4" scaleMode="normal" weight="2"/>
                                </s:stroke>
                            </s:Rect>
                            <s:Rect height="358" ai:objID="644a1c90" width="289" x="1" y="1">
                                <s:fill>
                                    <s:SolidColor color="0x232323"/>
                                </s:fill>
                            </s:Rect>
                        </s:Group>
                        <s:List skinClass="components.DataList3" x="65" y="96" change="list_changeHandler()" id="list1" creationComplete="list1_creationCompleteHandler(event)" dataProvider="{TypeUtility.convertToCollection(indexResult.lastResult)}" labelField="student_request">
                        </s:List>
                    </fx:DesignLayer>