7 Replies Latest reply on Dec 3, 2007 7:42 PM by jnicholson

    Posting flex data to coldfusion

    jnicholson Level 1
      I am programming an application which passes form data such as checkboxes and filenames to coldfusion. I am trying to figure out what is the best method for passing the data. If anyone has code examples for passing checkboxes and Arraycollections it would be greatly appreciated.
        • 1. Re: Posting flex data to coldfusion
          So your basically want examples of like inserting the data from flex - coldfusion - database?
          • 2. Re: Posting flex data to coldfusion
            jnicholson Level 1
            Yes, that would be great. I am trying to pass the check box selected status to a cfc page. The filename would be passed to the end of the command I am trying to execute in coldfusion. The filenames are stored in an array collection.
            <cfif cb Is "true">
            <cfexecute>do this</cfexecute>
            Thank you for your assistance,
            • 3. Re: Posting flex data to coldfusion
              GeorgeWS Level 1
              Im going like this:


              private function sendFormdata():void {
              var myobj:Object = new Object();
              myobj.dba = dba.selectedLabel;
              myobj.itemid = itemid.text;
              myobj.tracksales = tracksales.selected;
              myobj.startdate = startdate.selectedDate;


              <mx:FormItem id="DBA">
              <mx:ComboBox id="dba" dataProvider="{myCustomers}" labelField="label" width="250"
              close="selectedItem=ComboBox(event.target).selectedItem" change="myAccounts.refresh()"/>

              <mx:FormItem id="ItemID">
              <mx:TextInput id="itemid" text="{item.selectedItem.data}" visible="false" width="0" includeInLayout="false"/>

              <mx:FormItem id="TrackSales" label="Track Sales">
              <mx:CheckBox id="tracksales" enabled="true"/>

              <mx:FormItem id="StartDate" label="Start">
              <mx:DateField id="startdate" width="100" yearNavigationEnabled="true" />

              THIS CALLS THE sendFormData()

              <mx:FormItem id="FI_BTN_send">
              <mx:Button label="Send" click="collectForInclude();sendFormdata()"
              enabled="true" labelPlacement="right"/>

              THE CFC IS LIKE:

              <cffunction name="addData" output="false" access="remote" returntype="string">

              <cfargument name="user" required="no" type="struct">

              <cfquery name="qCreate" datasource="myDB">
              INSERT INTO dbo.myTable
              (DBA, itemid, tracksales, startdate)
              <cfqueryparam value="#user.dba#" cfsqltype="CF_SQL_CHAR" />,
              <cfqueryparam value="#user.itemID#" cfsqltype="CF_SQL_CHAR" />,
              <cfqueryparam value="#user.tracksales#" cfsqltype="CF_SQL_CHAR" />,
              <cfqueryparam value="#user.startdate#" cfsqltype="cf_sql_date" />,


              Hope this helps

              • 4. Posting flex data to coldfusion
                kausi21 Level 1
                What George said, is the right way to do things. I'm also new to flex, and I have yet to ever be able to get structures to work with remote objects. I always get function is required, but not passed error. With that said I will show you how I would do a check box, and you can decide the way you want to do it.

                MY CFC FILE

                <cffunction name="cCheckbox" access="remote" returntype="void">
                <cfargument name="checkbox" default="" type="boolean" required="no">
                <cfquery name="crcheckbox" datasource="yourdatabase">
                INSERT INTO
                ( <cfif arguments.checkbox>

                SEND TO CFC FROM FLEX

                private function checkboxChecked():void


                This is not best practice, but it works for me. Also I was just showing you how I would do a check box. If i was doing a form I would name my function like creatClient, and just go down the line INSERT INTO dbo.yourdatabase(checkbox,firstname,lastname,address)
                • 5. Re: Posting flex data to coldfusion
                  jnicholson Level 1
                  How are you calling the cfc? Is it a webservice, httpservice or remote object?
                  Thank you,
                  • 6. Re: Posting flex data to coldfusion
                    jnicholson Level 1

                    I receive the message below when using your post below. Any suggestions? I am using this as a webservice.

                    [RPC Fault faultString="Array of input arguments did not contain a required parameter at position 1" faultCode="Client.Input" faultDetail="null"]
                    at mx.rpc.soap::Operation/createFaultEvent()[C:\dev\enterprise_bali\frameworks\mx\rpc\soap\O peration.as:709]
                    at mx.rpc.soap::Operation/ http://www.adobe.com/2006/flex/mx/internal::invokePendingCall()[C:\dev\enterprise_bali\fra meworks\mx\rpc\soap\Operation.as:576
                    at mx.rpc.soap::Operation/send()[C:\dev\enterprise_bali\frameworks\mx\rpc\soap\Operation.as: 492]
                    at Function/ http://adobe.com/AS3/2006/builtin::apply()
                    at mx.rpc.soap.mxml::Operation/send()[C:\dev\enterprise_bali\frameworks\mx\rpc\soap\mxml\Ope ration.as:140]
                    at Function/ http://adobe.com/AS3/2006/builtin::apply()
                    at mx.rpc::AbstractService/ http://www.adobe.com/2006/actionscript/flash/proxy::callProperty()[C:\dev\enterprise_bali\ frameworks\mx\rpc\AbstractService.as:287
                    at FlexFileUpload/convertEventHandler()[C:\Documents and Settings\jnicholson\My Documents\Flex Builder 3\MultiFileUpload\FlexFileUpload_cb.as:45]
                    at FlexFileUpload/__convert_btn_click()[C:\Documents and Settings\jnicholson\My Documents\Flex Builder 3\MultiFileUpload\FlexFileUpload.mxml:58]
                    • 7. Re: Posting flex data to coldfusion
                      jnicholson Level 1
                      OK, I fixed the last error by uploading the new cfc to the server... duh. I am now getting a new error:
                      [RPC Fault faultString="HTTP request error" faultCode="Server.Error.Request" faultDetail="Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL:" URL:"
                      at mx.rpc::AbstractInvoker/ http://www.adobe.com/2006/flex/mx/internal::faultHandler()[C:\dev\enterprise_bali\framewor ks\mx\rpc\AbstractInvoker.as:193
                      at mx.rpc::Responder/fault()[C:\dev\enterprise_bali\frameworks\mx\rpc\Responder.as:56]
                      at mx.rpc::AsyncRequest/fault()[C:\dev\enterprise_bali\frameworks\mx\rpc\AsyncRequest.as:107 ]
                      at DirectHTTPMessageResponder/errorHandler()[C:\dev\enterprise_bali\frameworks\mx\messaging\ channels\DirectHTTPChannel.as:323]
                      at flash.events::EventDispatcher/dispatchEventFunction()
                      at flash.events::EventDispatcher/dispatchEvent()
                      at flash.net::URLLoader/redirectEvent()

                      HELP Please