2 Replies Latest reply on Sep 3, 2010 7:46 PM by VPX969-1

    how to search the text field with an int.

    Jun yuan

      I followed the steps on http://www.adobe.com/devnet/flex/testdrive/articles/1_build_a_flex_app4.html

      and got stuck at this step 6:

       

      Step 6: Load new data on a click event.

      Using the Data/Services view, configure the getEmployeesByName() operation to return an array of existing Employee objects; enter a parameter value of Smith when auto-detecting from sample data. Drag the getEmployeesByName() operation onto the Search button. Inside the generated event handler, pass the user-entered value which is held in searchTxt.text to the operation. Change the responder to be the existing getEmployeesResult responder. Apply the searchBtn click event to all states.

      By default, a new responder getEmployeesByNameResult is created:

      <s:CallResponder id="getEmployeesByNameResult"/>

      ... and used for the service call:

      protected function searchBtn_clickHandler(event:MouseEvent):void
      {
         getEmployeesByNameResult.token =
         employeeService.getEmployeesByName(searchTxt.text);
      }

       

      I am using another data set and that data set only has getEmployeesByID, when i do the same steps, this error occured:

      1067: Implicit coercion of a value of type String to an unrelated type int. test1.mxml /test1/src line 50 Flex Problem

        • 2. Re: how to search the text field with an int.
          VPX969-1 Level 1

          Hi Jun,

          Not sure if this is an acceptable answer but it fixed the problem for me and allowed me to move forward with the lesson. I was trying to figure out how the data service was built and it dawned on me that it was simply a PHP file so I modified it by adding the missing function for finding the employee by last name:

           

              public function getEmployeesByName($name) {
                 
                  $stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename where lastname=?");
                  $this->throwExceptionOnError();
                 
                  mysqli_stmt_bind_param($stmt, 'i', $name);       
                  $this->throwExceptionOnError();
                 
                  mysqli_stmt_execute($stmt);
                  $this->throwExceptionOnError();
                 
                  mysqli_stmt_bind_result($stmt, $row->id, $row->firstname, $row->lastname, $row->title, $row->departmentid, $row->officephone, $row->cellphone, $row->email, $row->street, $row->city, $row->state, $row->zipcode, $row->office, $row->photofile);
                 
                  if(mysqli_stmt_fetch($stmt)) {
                    return $row;
                  } else {
                    return null;
                  }
              }

           

          Hope this helps.

          Enjoy...

          Vern