1 Reply Latest reply on Sep 8, 2010 2:39 PM by Flex in a Week, FiaW

    Debugging Questions

    Jun yuan Level 1

      The code : error 1067: Implicit coercion of a value of type String to an unrelated type int.

      Can a text field accept an integer value?

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:customerservice="services.customerservice.*" xmlns:salesrepservice="services.salesrepservice.*" xmlns:valueObjects="valueObjects.*">
      <fx:Script>
        <![CDATA[
         import mx.controls.Alert;
         import mx.events.FlexEvent;
         import mx.events.ListEvent;
        
         protected function dataGrid_creationCompleteHandler(event:FlexEvent):void
         {
          getAllCustomerResult.token = customerService.getAllCustomer();
         }
        
        
         protected function dataGrid2_creationCompleteHandler(event:FlexEvent):void
         {
          getAllSales_repResult.token = salesrepService.getAllSales_rep();
         }
        
        
         protected function empBtn_clickHandler(event:MouseEvent):void
         {
          currentState="employee";
         }
        
        
         protected function custBtn_clickHandler(event:MouseEvent):void
         {
          currentState="customer";
         }
        
        
         protected function search_focusInHandler(event:FocusEvent):void
         {
          if(search.text=="enter id")
          {search.text="";}
         }
        
        
         protected function dataGrid2_changeHandler(event:ListEvent):void
         {
          currentState="employeedet";
         }
        
        
         protected function searchBtn_clickHandler(event:MouseEvent):void
         {
          getSales_repByIDResult.token = salesrepService.getSales_repByID(search.text);
         }
        
        ]]>
      </fx:Script>
      <s:states>
        <s:State name="customer"/>
        <s:State name="employee"/>
        <s:State name="employeedet"/>
      </s:states>
      <fx:Declarations>
        <s:CallResponder id="getAllCustomerResult"/>
        <customerservice:CustomerService id="customerService" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
        <s:CallResponder id="getAllSales_repResult"/>
        <salesrepservice:SalesrepService id="salesrepService" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
        <valueObjects:Sales_rep id="sales_rep"/>
        <s:CallResponder id="getSales_repByIDResult"/>
        <s:CallResponder id="getSales_repByIDResult2"/>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
      </fx:Declarations>
      <fx:Binding source="dataGrid2.selectedItem as Sales_rep" destination="sales_rep"/>
      <mx:DataGrid x="90" y="180" id="dataGrid" creationComplete="dataGrid_creationCompleteHandler(event)" dataProvider="{getAllCustomerResult.lastResult}" includeIn="customer">
        <mx:columns>
         <mx:DataGridColumn headerText="id" dataField="id"/>
         <mx:DataGridColumn headerText="cfirst_name" dataField="cfirst_name"/>
         <mx:DataGridColumn headerText="clast_name" dataField="clast_name"/>
        </mx:columns>
      </mx:DataGrid>
      <s:Label x="212" y="94" text="Data" id="title1" fontSize="25"/>
      <s:Button x="117" y="129" label="customer" id="custBtn" enabled.customer="false" click="custBtn_clickHandler(event)"/>
      <s:Button x="289" y="129" label="employee" id="empBtn" enabled.employee="false" enabled.employeedet="false" click="empBtn_clickHandler(event)"/>
      <mx:DataGrid includeIn="employee,employeedet" x="108" y="172" id="dataGrid2" change="dataGrid2_changeHandler(event)" creationComplete="dataGrid2_creationCompleteHandler(event)" dataProvider="{getAllSales_repResult.lastResult}" x.employeedet="10" y.employeedet="171">
        <mx:columns>
         <mx:DataGridColumn headerText="employee_no" dataField="employee_no"/>
         <mx:DataGridColumn headerText="esurname" dataField="esurname"/>
         <mx:DataGridColumn headerText="efirstname" dataField="efirstname"/>
         <mx:DataGridColumn headerText="commission" dataField="commission"/>
         <mx:DataGridColumn headerText="date_joined" dataField="date_joined"/>
        </mx:columns>
      </mx:DataGrid>
      <s:TextInput includeIn="employeedet" x="62" y="357" id="search" text="enter id" focusIn="search_focusInHandler(event)"/>
      <s:Button includeIn="employeedet" x="213" y="357" label="Search" id="searchBtn" click="searchBtn_clickHandler(event)"/>
      <mx:Form includeIn="employeedet" x="31" y="407">
        <mx:FormItem label="Employee_no">
         <s:Label id="employee_noLabel" text="{sales_rep.employee_no}"/>
        </mx:FormItem>
        <mx:FormItem label="Esurname">
         <s:Label id="esurnameLabel" text="{sales_rep.esurname}"/>
        </mx:FormItem>
        <mx:FormItem label="Efirstname">
         <s:Label id="efirstnameLabel" text="{sales_rep.efirstname}"/>
        </mx:FormItem>
        <mx:FormItem label="Commission">
         <s:Label id="commissionLabel" text="{sales_rep.commission}"/>
        </mx:FormItem>
        <mx:FormItem label="Date_joined">
         <mx:DateField enabled="false" id="date_joinedDateField" selectedDate="{sales_rep.date_joined}"/>
        </mx:FormItem>
      </mx:Form>
      </s:Application>