3 Replies Latest reply on Nov 14, 2006 10:29 AM by ciwee_ufrj

    Problems with DataService

    ciwee_ufrj
      Hi all,
      I tried to make the most simple program I could imagine and didnt work! :(
      I'll describe the steps I took here and you guys try to figure what's wrong OK? thank you!:

      The index.mxml is as follows:
      quote:


      <?xml version="1.0"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">
      <mx:DataService id="ds" destination="users"/>
      <mx:ArrayCollection id="usersCollection"/>
      <mx:DataGrid id="dg" dataProvider="{usersCollection}" editable="false">
      <mx:columns>
      <mx:DataGridColumn dataField="name" headerText="User Name"/>
      </mx:columns>
      </mx:DataGrid>
      <mx:Button label="Get Data" click="ds.fill(usersCollection)"/>
      </mx:Application>


      this code should just show a single-column list of users

      Now the server-side configuration:

      The destination:
      quote:


      <destination id="users">
      <adapter ref="java-dao" />
      <properties>
      <source>chat.UsersAssembler</source>
      <scope>application</scope>
      <cache-items>true</cache-items>
      <metadata>
      <identity property="name"/>
      </metadata>
      <network>
      <session-timeout>20</session-timeout>
      <paging enabled="true" pageSize="10" />
      <throttle-inbound policy="ERROR" max-frequency="500"/>
      <throttle-outbound policy="REPLACE" max-frequency="500"/>
      </network>
      <server>
      <fill-method>
      <name>loadUsers</name>
      </fill-method>
      <sync-method>
      <name>syncUsers</name>
      </sync-method>
      </server>
      </properties>
      </destination>


      I asure that the adapter existis and the rmtp channel is configured

      Now the Java code, Im in doubt of the folder hierarchy... so I'll put the one I used here

      my application is inside flex directory in default server so the classes go here
      C:\fds2\jrun4\servers\default\flex\WEB-INF\classes

      I created a package chat as I described in the destination and put 2 files within it

      User.class as follows
      quote:


      package chat;

      public class User {
      private String name;

      User(String name){
      this.name = name;
      }

      public void setName(String name){
      this.name = name;
      }

      public String getName(){
      return name;
      }
      }


      and UserAssembler as follows
      quote:


      package chat;

      import java.util.ArrayList;
      import java.util.List;

      public class UsersAssembler {
      public List loadUsers(){
      ArrayList myList = new ArrayList();
      myList.add(new User("Andre"));
      myList.add(new User("Japa"));
      myList.add(new User("Flay"));
      return myList;
      }

      public void syncUsers(){
      }
      }


      I didnt define sync method because I didnt use it in the application

      I wrote this useless simple application just to test, but when I press the button to fill my ArrayCollection no data is retrieved..

      The error I get is:
      quote:


      [RPC Fault faultString="Send failed" faultCode="Client.Error.MessageSend" faultDetail="Channel.Connect.Failed error null"]
      at mx.data::ConcreteDataService/ http://www.adobe.com/2006/flex/mx/internal::dispatchFaultEvent()
      at ::DataListRequestResponder/fault()
      at mx.rpc::AsyncRequest/fault()
      at mx.messaging::ChannelSet/::faultPendingSends()
      at mx.messaging::ChannelSet/channelFaultHandler()
      at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at mx.messaging::Channel/mx.messaging:Channel::connectFailed()
      at mx.messaging.channels::PollingChannel/mx.messaging.channels:PollingChannel::connectFailed ()
      at mx.messaging.channels::RTMPChannel/mx.messaging.channels:RTMPChannel::statusHandler()



      The grid shows empty.. anyone knows why???
      thanks