0 Replies Latest reply on Jun 29, 2009 1:18 PM by RosieGp

    Flex Txt Input Controls

    RosieGp Level 1

      I'm new to flex and need some help...
      I have a combo box which have 2 options get data from SQL based on either Employee Name or Employee ID and next to it is text input box to enter the name or id. This is all in my mainapp.mxml. In my EmpRef.mxml I have datagrid and cold fusion connection coding. I'm confused how can I save user input entered in mainapp.mxml and based on it display data in EmpRef.mxml...
      This is how my mainapp.mxml looks:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundColor="0xFFFFFF" left="10" right="10" top="10" bottom="10" creationComplete="init()" xmlns:src="*">
          <mx:Script>
              <![CDATA[
                  import mx.controls.Alert;
                  import mx.controls.Alert;
                  import mx.collections.ArrayCollection;
                  import mx.rpc.events.ResultEvent;
                  import mx.rpc.events.FaultEvent;
                  import mx.controls.dataGridClasses.DataGridColumn;
                  import mx.utils.ObjectUtil;
                             
                  [Bindable] public var aryTXT:Array = ["Employee Name", "Employee ID"];
                             
                  private function init():void {
                  }
              ]]>
          </mx:Script>
         
          <mx:ComboBox id="cbTXT" x="10" y="31" dataProvider="{aryTXT}" fontSize="10" fontWeight="bold" width="170"></mx:ComboBox>     
          <mx:Label x="10" y="0" text="Employee Data" fontWeight="bold" fontSize="17"/>
          <mx:TextInput id="txt" x="188" y="32" width="170" height="24" fontSize="12" color="#3333ff" restrict="A-Z a-z 012345689"/>
          <mx:Button x="366" y="32" label="Search" fontSize="10" color="0x3333ff" click="vs.selectedChild=vsEmpRef"/>
          <mx:Button id="clearBtn" label="Clear" click="txt.text =''" color="0x3333ff"  x="439" y="32" width="65"/>
          <mx:ViewStack id="vs" left="0" right="20" bottom="10" top="62">       
              <mx:Canvas label="View 1" width="100%" height="100%">
              </mx:Canvas>
              <src:EmpRef id="vsEmpRef" width="100%" height="100%"/>
          </mx:ViewStack>
      </mx:Application>

       

      and this how EmpRef.mxml looks like:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" x="0" y="0" width="1200" height="766" creationComplete="initEmpRef()">
          <mx:Script>
          <![CDATA[
                  import mx.utils.ArrayUtil;
                  import mx.controls.Alert;
                  import mx.collections.ArrayCollection;
                  import mx.rpc.events.ResultEvent;
                  import mx.rpc.events.FaultEvent;
                  import mx.controls.dataGridClasses.DataGridColumn;
                 
                  [Bindable] public var EmpDataProvider:ArrayCollection;
                 
                  private function initEmpRef():void {       
                      cf.getData();           
                  }
                  private function resultgetData(event:ResultEvent):void{
                      EmpDataProvider = ArrayCollection(event.result);
                      if(EmpDataProvider.toString()==''){Alert.show("No Data to Display");}
                  }               
          ]]>
          </mx:Script>

          <!--Database Server Connection -->
          <mx:RemoteObject id="cf" destination="ColdFusion" source="Emp-debug.CFC.EmpRef" showBusyCursor="true">
              <mx:method name="getData" result="resultgetData(event)" fault="Alert.show(event.fault.message)"/>
          </mx:RemoteObject>        
              <mx:DataGrid id="OrderGrid" dataProvider="{EmpDataProvider}" left="10" right="10" bottom="60" top="10">
                  <mx:columns>     
                        <mx:DataGridColumn headerText="Emp Name" dataField="Emp_Name"/>    
                          <mx:DataGridColumn headerText="Emp Number" dataField="Emp_Number"/>   
                          <mx:DataGridColumn headerText="LAST UPDATED" dataField="GroupSuffix"/>
                       </mx:columns>
              </mx:DataGrid>
      </mx:Canvas>

       

      and here is my CFC file:

      <cfcomponent output="false">
      <cffunction name="getData" access="remote" returnType="query" output="false">
          <cfset var DataQRY ="">
      <cfquery datasource="SQL" username="User" password="PWD" name="DataQRY">
                  select Emp_Name, Emp_Number
                  from   Employee
              </cfquery>
          <cfreturn DataQRY>
          </cffunction>
      </cfcomponent>

       

      I really appreciate any help and thank in advance...
      If you have any working example please refer me to it.
      Thanks.