3 Replies Latest reply on Jul 13, 2010 4:09 PM by =Big-Div=

    Search Function not working - does my code look right ?

    =Big-Div=

      Hi ! I've just completed the tutorial for Flash Builder with the whole department pages and all that, I've moved straight on to making my very own application. Below is the code so far. For some strange reason though, when trying to complete a search is displays only the first record in the table only and not what i actually searched for    Excuse the nubness.... Thank you for helping

       

      <?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:usersservice="services.usersservice.*" xmlns:valueObjects="valueObjects.*">

      <fx:Style source="Main.css"/>

      <fx:Script>

      <![CDATA[

      import mx.controls.Alert;

      import mx.events.FlexEvent;

       

      protected function dataGrid_creationCompleteHandler(event:FlexEvent):void

      {

      getAllUsersResult.token = usersService.getAllUsers();

      }

       

       

      protected function searchtxt_focusInHandler(event:FocusEvent):void

      {

      if (searchtxt.text=="Enter Service No.") searchtxt.text = "";

      searchbtn.enabled=true;

      }

       

       

      protected function searchtxt_focusOutHandler(event:FocusEvent):void

      {

      if (searchtxt.text=="") searchtxt.text = "Enter Service No.";

      searchbtn.enabled=false;

      }

       

      protected function searchbtn_clickHandler(event:MouseEvent):void

      {

      getAllUsersResult.token = usersService.getUsersByID(searchtxt.text);

       

       

      }

       

      protected function showall_clickHandler(event:MouseEvent):void

      {

      getAllUsersResult.token = usersService.getAllUsers();

      searchtxt.text="Enter Service No.";

       

      }

       

       

      protected function label2_creationCompleteHandler(event:FlexEvent):void

      {

      countResult.token = usersService.count();

      }

       

      ]]>

      </fx:Script>

      <fx:Declarations>

      <s:CallResponder id="getAllUsersResult"/>

      <usersservice:UsersService id="usersService" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>

      <valueObjects:Users id="users"/>

      <s:CallResponder id="getUsersByIDResult"/>

      <s:CallResponder id="countResult"/>

       

       

      <!-- Place non-visual elements (e.g., services, value objects) here -->

      </fx:Declarations>

      <fx:Binding source="dataGrid.selectedItem as Users" destination="users"/>

      <s:Label x="41.9" y="10.35" text="User Manager" fontSize="26"/>

      <mx:DataGrid x="41.55" y="76.25" id="dataGrid" creationComplete="dataGrid_creationCompleteHandler(event)" dataProvider="{getAllUsersResult.lastResult}" width="872">

      <mx:columns>

      <mx:DataGridColumn headerText="Service Number" dataField="roll_no"/>

      <mx:DataGridColumn headerText="rank" dataField="rank"/>

      <mx:DataGridColumn headerText="First Name" dataField="first_name"/>

      <mx:DataGridColumn headerText="Second Name" dataField="second_name"/>

      <mx:DataGridColumn headerText="Email" dataField="email"/>

      </mx:columns>

      </mx:DataGrid>

      <mx:Form x="41.5" y="250.05">

      <mx:FormItem label="Service #">

      <s:Label id="roll_noLabel" text="{users.roll_no}"/>

      </mx:FormItem>

      <mx:FormItem label="Rank">

      <s:Label id="rankLabel" text="{users.rank}"/>

      </mx:FormItem>

      <mx:FormItem label="First Name">

      <s:Label id="first_nameLabel" text="{users.first_name}"/>

      </mx:FormItem>

      <mx:FormItem label="Last Name">

      <s:Label id="second_nameLabel" text="{users.second_name}"/>

      </mx:FormItem>

      <mx:FormItem label="Sex">

      <s:Label id="sexLabel" text="{users.sex}"/>

      </mx:FormItem>

      <mx:FormItem label="Email">

      <s:Label text="{users.email}&#xd;"/>

      </mx:FormItem>

      <mx:FormItem label="Items Issued">

      <s:Label id="items_issuedLabel" text="{users.items_issued}"/>

      </mx:FormItem>

      <mx:FormItem label="Access">

      <s:Label id="accessLabel" text="{users.access}"/>

      </mx:FormItem>

      </mx:Form>

      <s:TextInput x="78.55" y="43" id="searchtxt" text="Enter Service No." focusIn="searchtxt_focusInHandler(event)" focusOut="searchtxt_focusOutHandler(event)"/>

      <s:Button x="229.4" y="43" label="Search" id="searchbtn" click="searchbtn_clickHandler(event)" enabled="false"/>

      <s:Button x="307.25" y="42.8" label="Show All" id="showall" click="showall_clickHandler(event)"/>

      <s:Label x="511.7" y="47.7" id="searchlabel" text="" fontSize="13" width="133"/>

      <s:Label x="400" y="48" width="129" height="20" fontSize="13" id="searchingfor"/>

      <s:Label x="873.3" y="255.3" text="{countResult.lastResult}" id="label2" creationComplete="label2_creationCompleteHandler(event)"/>

      </s:Application>