0 Replies Latest reply on Sep 21, 2006 12:50 PM by lenny2

    selectedIndex and Value Objects

      Please Please Please!!! been searching and trying a million things for days and can't figure this out....

      In a custom container I have a data grid custom component that displays results from a remote object call to a cfc. When the user clicks on an item I'd like to populate form items in a form container that resides in the custom container (i.e. NOT a a seperate custom component). I've created a value object class called Employee (actually the CF wizard did) in a file called Employee.as.

      In the custom container I import the employee class as such: import comp.Employee.

      In the initialize event handler of the custom container I create an instance of the employee class as such:
      oEmployee = new Employee();

      In the click event handler of the custom datagrid component I want to populate the oEmployee object with the record the user clicked on as such: oEmployee = myGrid.selectedItem as Employee.

      The above code compiles just fine. But when I click on the grid I get the "null object has no properties" error. This didn';t tell me much so I changed the code to use the AS2 casting code as such:
      oEmployee = Employee(myGrid.selectedItem)

      This also compiles just fine put ar run time throws this error:
      Type Coercion failed: cannot convert Object@9a00b01 to comp.Employee.

      I thought I saw examples somewhere of someone passing a selectedItem object to a custom class but I cannot get it to work. Must I write code like such: oEmployee.first_name = myGrid.selectedIndex.first_name?? My VO has a lot of data in it and this would be tedious. I could just bypass the whole vo thing and simple write:
      myFormItem.first_name = myGrid.selectedItem.first_name but a) that doesn';t promote loose coupling between generic components and b) I would like to use the data in the oEmployee vo to pass to a cfc in a save method.

      Thanks in advance for any help on this!!