3 Replies Latest reply on Oct 9, 2006 11:15 AM by T._Ruggles

    i found a bug while using the DataService component

    dimival Level 1
      I found a bug, it happens when you pass an AS object to the fill method of a DataService component, like this:

      dataService.fill(arrayCollection, customObject);

      where customObject is an instance of the CustomObject AS class, which has the remote alias metadata pointing to CustomObject Java class.

      On the Assembler i have this:

      public Collection fill(List fillParameters) {
      CustomObject custom = (CustomObject) fillParameters.get(0);
      resultados = dao.find(custom);
      return resultados;
      }

      Whenever you call the fill method from Flex it works, when if you use the createItem( ) method to add a new item, when it is committed, an autoRefresh is triggered but the arrayCollection on Flex is not receiving this change.

      If you pass a primitive type of object, the assembler works perfectly fine, so the BUG is that you can't pass AS objects that map to a Java object because the autoRefresh strategy will fail after creating a new item.

      Who do i report this to? it is really wrong that you can't pass an object and expect it to work

      Reproducing this bug

      If you want to reproduce this bug, it is very simple, open the crm example that comes with the Flex 2 installation. Find the EmployeeAssembler.java and change the fill implementation for the following code:

      public Collection fill(List fillParameters)
      {
      EmployeeDAO dao = new EmployeeDAO();
      if (fillParameters.size() == 0)
      return dao.getEmployees();

      Company cpy = (Company) fillParameters.get(0);
      return dao.findEmployeesByCompany(cpy.getCompanyId);
      }

      Then on the companyapp.mxml find and replace all lines like this:

      dsEmployee.fill(employees, "byCompany", company.companyId);
      for this:
      dsEmployee.fill(employees, company);

      Then replace this line:
      employees.addItem(employee);
      for
      dsEmployee.createItem(employee);

      Recompile the Assembler and replace the previous EmployeeAssembler.class and there you have it, whenever you add an employee to a company's list of employees you will notice that the list is not autorefreshed, it doesnt show the recently added item

      Debugging

      I debugged the application twice, once with the original code and one after the changes mentioned above. The output for the original code (passing a primitive object, the companyId as an int) after a createItem statement was:

      [Flex] [DEBUG] Queuing refresh fill till commit for crm.employee with parameters: []
      [Flex] [DEBUG] Queuing refresh fill till commit for crm.employee with parameters: [byCompany, 5]
      [Flex] [DEBUG] Committed transaction
      [Flex] [DEBUG] Refresh fill: destination=crm.employee fillParameters=[] matched no sequences currently managed on clients.
      [Flex] [DEBUG] Committed transaction
      [Flex] [DEBUG] Refresh fill: destination=crm.employee fillParameters=[byCompany, 5] refreshed: 1 fills

      Notice that in the last line it says that it refreshed 1 fill!!!!

      Now the debug output after the changes (sending the whole company object) after the createItem:

      Flex] [DEBUG] Queuing refresh fill till commit for crm.employeetest with parameters: []
      Flex] [DEBUG] Queuing refresh fill till commit for crm.employeetest with parameters: [Company(companyId=4, name=Adobe Systems~, address=453 S 34th St, stateCA, zip=2544799 industry=Computers)]
      Flex] [DEBUG] Committed transaction
      Flex] [DEBUG] Refresh fill: destination=crm.employeetest fillParameters=[] matched no sequences currently managed on clients.
      Flex] [DEBUG] Refresh fill: destination=crm.employeetest fillParameters=[Company(companyId=4, name=Adobe Systems~, address=453 S 34th St, stateCA, zip=2544799 industry=Computers)] matched no sequences currently managed on clients.

      As you can see, if i send the whole object to the fill method and then i create an new item, the fill is not being autorefreshed.

      What do i do??????? i really need to send the whole object