0 Replies Latest reply on Oct 16, 2009 1:52 PM by sunMessak

    example flex and cf insert into access?


      i know this is asking a lot, but i seem to be having difficulties and figured i would ask. So i am attempting to build a flex form that queries a cfc to populate a combobox, there are also datepickers and a few text boxes. This data is then passed back to a cfc to insert into and access db. I seem to have the querying down with flex and cfc's, however i can't seem to get the data passed back to the cfc to insert into the db. I populated the values in the cfc and it inserts, so it's working, just not received the data.

           would it be possible to post a flex example of taking a selected item and a text box and passing it back to a cfc? I think the date picker is just a textbox, so that shouldn't be a problem.


      Thanks in advance.



      Below is the code that i have, yet doesn't seem to work.


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"  creationComplete="init();displayDate();MailLogRequest.send(); initApp()" >
      <mx:Style source="assets/skins/flex_skins.css"/>    
      <mx:RemoteObject id="con" showBusyCursor="true" destination="ColdFusion" source="MailTracker.SubVendorName">
              <mx:method name="getSubVendorName" result="getSubVendorNameSuccess(event)" fault="fault(event)" />
                  import mx.rpc.events.FaultEvent;
                  import mx.collections.ArrayCollection;
                  import mx.rpc.events.ResultEvent;
                  import mx.controls.Alert;
                  private var receivedData:ArrayCollection;
                  private var comboDisplay:String = "Name";
                  private function getSubVendorNameSuccess(returnedEvent:ResultEvent):void{
                      receivedData = returnedEvent.result as ArrayCollection;
                  private function init():void{
         //             file.addEventListener( Event.SELECT, doSelect );
                  private function fault(f:FaultEvent):void{
                      Alert.show(f.message as String);
                  private var acMail:ArrayCollection;
                  private function initApp():void
                  private function getMailRO_Handler(event:ResultEvent):void
                      acMail = ArrayCollection(event.result);
        import mx.controls.Alert;
          private function clickHandler():void {
          MailLogRequest.InsertRecord(ReceivedSent.selection.label , ReceivedSentDate.text , PhaseID.selection.label , SubPhase.text , SubVendorName.text , Subject.text ,Remarks.text);
          ReceivedSent.selection.label = "";
          ReceivedSentDate.text = "";
          PhaseID.selection.label = "";
          SubPhase.text = "";
          SubVendorName.text = "";
          Subject.text = "";
          Remarks.text = "";
          Alert.show('Record Inserted!', 'Alert Box', mx.controls.Alert.OK);
                   public function displayDate():void {
                                      var now:Date = new Date();
                      var day_int:int = now.getDate(); //gets day of the month
                      var month_int:int = (now.getMonth()+1); // gets month. Months are given from 0 to 11, so you need to do +1 here
                      var year_int:int = now.getFullYear(); // gets year
                      var day_string:String;
                      //display always 2 digits for a month, so '02' instead of just '2' for February
                      if (day_int < 10) {
                          day_string = "0" + day_int.toString();
                      else {
                          day_string = day_int.toString();
                      var month_string:String;
                      //display always 2 digits for a day, so '02' instead of just '2'
                      if (month_int < 10) { 
                          month_string = "0" + month_int.toString();
                      else {
                          month_string = month_int.toString();
                      var year_string:String = year_int.toString();
                      // note: this is displaying the date in the MM/DD/YYYY format, this same format is also set for the Datefield below!
                      ReceivedSentDate.text = month_string + "/" + day_string + "/" + year_string;
                  import mx.controls.DateField;
                      // Formats date columns in DataGrids
                      public function dateFunc(item:Object, column:DataGridColumn):String
                          return dateFormatter.format(item[column.dataField]);
      <mx:RemoteObject id="MailTrackerGateway_RO" destination="ColdFusion" source="MailTracker.MailTrackerGateway">
              <mx:method name="getMail" result="getMailRO_Handler(event)"/>
          <mx:WebService id="MailLogRequest" wsdl="http://localhost:8600/Post.cfm">
            <mx:operation name="InsertRecord" fault="mx.controls.Alert.show(event.fault.faultString)"/>
      <mx:DateFormatter id="dateFormatter" formatString="MM/DD/YY" />    
      <mx:Canvas x="0" y="0" width="100%" height="100%" borderStyle="inset" backgroundColor="#949EFA">
      <!--    <mx:TabNavigator x="10" y="84" width="1028" height="678">
              <mx:Canvas label="Add Record" width="100%" height="100%" backgroundColor="#D0D7FB">
                  <mx:RadioButtonGroup id="ReceivedSent"/>
                  <mx:RadioButtonGroup id="PhaseID"/>
                  <mx:TabNavigator x="10" y="10" width="100%" height="100%">
                      <mx:Canvas label="Tab 1" width="100%" height="100%" backgroundColor="#F9EBB9">
                          <mx:Text x="71" y="237" text="Date Logged" width="91" id="DateLogged" fontSize="14" fontFamily="Arial" fontWeight="bold"/>
                          <mx:RadioButton x="71" y="282" label="Sent" groupName="ReceivedSent" id="Sent" fontFamily="Arial" fontWeight="bold" fontSize="14"/>
                          <mx:RadioButton x="151" y="282" label="Received" groupName="ReceivedSent" id="Received" fontFamily="Arial" fontWeight="bold" fontSize="14"/>
                          <mx:DateField x="254" y="282" formatString="MM/DD/YYYY" id="ReceivedSentDate"  width="103.5" height="26"/>
                          <mx:RadioButton x="71" y="339" label="Hickam I" groupName="PhaseID" fontFamily="Arial" fontWeight="bold" fontSize="14" id="HickamI"/>
                          <mx:RadioButton x="154" y="339" label="Hickam II" groupName="PhaseID" fontFamily="Arial" fontWeight="bold" fontSize="14" id="HickamII"/>
                          <mx:Label x="71" y="390" text="Sub Phase" fontFamily="Arial" fontSize="14" id="SubPhaseText" fontWeight="bold"/>
                          <mx:ComboBox x="210" y="392" id="SubPhase" width="165.5" height="20">
                                     <mx:String>Phase 1</mx:String>
                                     <mx:String>Phase 2</mx:String>
                                     <mx:String>Phase 3</mx:String>
                                     <mx:String>Phase 4</mx:String>
                          <mx:Label x="609.5" y="237" text="Sub/ Vendor Name" fontFamily="Arial" fontSize="14" id="SubVendorNameLabel" fontWeight="bold"/>
                          <mx:ComboBox x="748.5" y="237" id="SubVendorName" labelField="{comboDisplay}" dataProvider="{receivedData}" height="22"></mx:ComboBox>
                          <mx:Label x="609.5" y="281" text="Subject" id="SubjectText" fontFamily="Arial" fontWeight="bold" fontSize="14"/>
                          <mx:TextInput x="748.5" y="281" id="Subject" maxChars="255" height="22"/>
                          <mx:Label x="609.5" y="357" text="Remarks" id="RemarksLabel" fontFamily="Arial" fontWeight="bold" fontSize="14"/>
                          <mx:TextArea x="748.5" y="336" id="Remarks" height="43"/>
                          <mx:Button x="457" y="463" id="btnSubmit" label="Submit" click="clickHandler()" width="122" height="52"/>
                          <mx:Canvas x="0" y="0" width="100%" height="154" backgroundColor="#FFFFFF">
                              <mx:Image x="10" y="0" width="216" height="154" source="images/Logo-Actus_4in.jpg"/>
                          <mx:Label x="253.5" y="239" text="{ReceivedSentDate.text}" fontSize="14" fontFamily="Arial" fontWeight="bold"/>
                      <mx:Canvas label="Tab 2" width="100%" height="100%" backgroundColor="#F9EBB9">
                          <mx:Canvas x="0" y="0" width="100%" height="154" backgroundColor="#FFFFFF">
                              <mx:Image x="10" y="0" width="216" height="154" source="images/Logo-Actus_4in.jpg"/>
                          <mx:DataGrid x="0" y="162" width="100%" height="100%" dataProvider="{acMail}">
                      <mx:DataGridColumn headerText="MailID" width="200" dataField="MailID"/>
                      <mx:DataGridColumn headerText="Logged Date" width="100" labelFunction="dateFunc"  dataField="LoggedDate"/>
                      <mx:DataGridColumn headerText="Received/Sent" width="200" dataField="Received/Sent"/>
                      <mx:DataGridColumn headerText="PhaseID" width="100"  dataField="PhaseID"/>
                      <mx:DataGridColumn headerText="SubPhase" width="100" dataField="SubPhase"/>
                      <mx:DataGridColumn headerText="SubVendorName" width="100" dataField="SubVendorName"/>
                      <mx:DataGridColumn headerText="Subject" width="100" dataField="Subject"/>
                          <mx:DataGridColumn headerText="Path" width="100" dataField="Path"/>
                      <mx:DataGridColumn headerText="Remarks" width="100" dataField="Remarks"/>