3 Replies Latest reply on Sep 13, 2007 11:42 AM by levancho

    Flex component with HTTPService

    pubdyn Level 1
      OK, so I'm a Flex newbie so forgive me if I'm missing the obvious.

      I created a Flex component that references a HTTPService to populate a DataGrid with data. As a standalone .mxml file, it works fine. When I place it into a Flex application where the component is referenced, the grid shows up, but I get no data. I've tried referencing the HTTPService in the application itself, no luck. I've tried referencing the service in a creationComplete function on the application page, no luck. I'm sure there's just some little snippet that allows the service to run in the component...the component looks fine when I run it, I just don't get any data.
        • 1. Re: Flex component with HTTPService
          raghunathrao Level 1
          It would really help if you could post the basic code of your custom component, so that we can understand your problem better
          • 2. Re: Flex component with HTTPService
            pubdyn Level 1
            Thanks--actually I figured it out--I was overlooking something obvious. However, I have a new issue that I would genuinely appreciate assistance on.

            I am building a Flex app where I have 4 custom components. Each component calls a web service to pull data in. I am using an MXML application file to bring in each component with an additional component where the user can select a date range and submit that range to the various web services. So what I need to do is make the date fields public variables and then append those variables to the web service calls as name/value pairs.

            No matter what I do, I cannot seem to get the other components to recognize the date variables as public vars. I've written them out as variables as part of a public function, tried to make them bindable, nothing works...

            So for example, this is a simplified version of my date range component (using only one date), assuming I've named the component datebar.mxml:

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml" width="100%">
            <mx:Script>
            <![CDATA[

            public function clickHandler():void
            {
            var sdate:String = start_date.text;
            }
            ]]>
            </mx:Script>
            <mx:ApplicationControlBar width="100%" height="30">
            <mx:DateField id="start_date" />
            <mx:Button label="refresh" click="clickHandler();" />
            </mx:Label>
            </mx:ApplicationControlBar>
            </mx:Canvas>

            Then in another component using a web service, I place:
            <mx:HTTPService
            id="os_downloads"
            url=" http://publishingdynamics.com/service.asmx?start_date={datebar.sdate}"
            useProxy="false">

            Where {datebar.sdate} is the variable I'm referencing to get a value from. I get a constant error doing this. I've tried several varitions. I can successfully create a public variable in the same manner not using a form value and get the component to display that variable using the same syntax, where I reference the source component like: {datebar.myvar} so I know the namespace referene works.

            Admittedly I'm not a very good ActionScripter...
            • 3. Re: Flex component with HTTPService
              levancho Level 3
              instead of this : url=" http://publishingdynamics.com/service.asmx?start_date={datebar.sdate}"

              do create <mx:request xmlns=""> inside <mx:HTTPService as a nested attribute
              <mx:request xmlns="">
              <start_date>{datebar.sdate}</start_date>
              </mx:request>

              and change url to http://publishingdynamics.com/service.asmx