2 Replies Latest reply on Dec 7, 2007 10:26 AM by .robson.

    Flex DataService CreateItem method not called

    salman657@yahoo.com
      Hi, I am using Flex 3. I am trying to create an application using data service of Flex. I been able to develop the code which uses the fill (Collection c) method to get the records from DB. Now I want to create a row in DB and for that I am using createItem(Object o ) method. Some how the method in java is not called and application doesn't give me any script error or exception. Can any one help me on this.

      Here is the code
      ProjectVo.as
      [Managed]
      [RemoteClass(alias="com.rap.view.ProjectBean")]
      public class ProjectVO
      {
      public var id:int;
      ....

      ProjectBean.java
      public class ProjectBean implements java.io.Serializable{

      private int id;
      .....

      Project Assembler
      package com.rap.view;

      import java.util.Collection;
      import java.util.List;
      import java.util.Map;

      import flex.data.assemblers.AbstractAssembler;


      public class ProjectAssembler extends AbstractAssembler{

      public Collection fill(List fillArgs) {
      ProjectDAO projectDAO = new ProjectDAO();
      System.out.println("----- 33 ");
      Collection c = projectDAO.returnProjects();
      return c;
      }

      public Object getItem(Map identity) {
      ProjectDAO projectDAO = new ProjectDAO();
      ProjectBean prj = new ProjectBean();
      prj.setId(1);
      prj.setProjectName("ABC");
      return prj;
      }

      public void createItem (Object obj) {
      ProjectDAO projectDAO = new ProjectDAO();
      System.out.println("----- 33 ");
      ProjectBean prj = (ProjectBean)obj;
      projectDAO.insertProject(prj.getProjectName(), prj.getProjectDescription());
      }
      }
      Data Management Service.xml
      <destination id="project">

      <adapter ref="java-dao" />

      <properties>
      <source>com.rap.view.ProjectAssembler</source>
      <scope>application</scope>

      <metadata>
      <identity property="id"/>
      </metadata>

      <network>
      <session-timeout>20</session-timeout>
      <paging enabled="false" pageSize="10" />
      <throttle-inbound policy="ERROR" max-frequency="500"/>
      <throttle-outbound policy="REPLACE" max-frequency="500"/>
      </network>
      <item-class>com.rap.view.ProjectBean</item-class>
      </properties>
      </destination>

      Please help me in this.

      Regards
      Salman