0 Replies Latest reply on Mar 11, 2009 7:37 AM by flexguy

    BlazeDS Java to ActionScript

    flexguy
      Hello, I am trying to send certain data types from a Java back-end through BlazeDS to my Flex clients. I wrote a ant script that takes JAXWS generated types and converts them into ActionScript types. One problem that I am facing is that the Seq classes are not being translated. What I mean is that JAXWS classes that contain List get wrapped into a class name ClassBSeq which contains a List<T> object. From the Java back-end I send the JAXWS types in a List to BlazeDS. The List contain a Seq classes that have List<t>. It seems on the client side that the main List gets translated but any List after that are null. Seems like it translated the top level List but no other List after that. Is there a way to tell the channel, in this case a StreamingAMFChannel, to transverse the object being translated?

      Here some code to help with my explanation.

      The Java Type:

      package handjam.gmiContainer;

      import java.util.List;

      public class GMIContainer {

      public List dataObjects;
      public String methodName;

      public GMIContainer() {

      }

      public void setMethodName(String methodName) {
      this.methodName=methodName;
      }

      public void setDataObjects(List dataObjects) {
      this.dataObjects=dataObjects;
      }

      }

      The ActionScript Type:

      package generated.handjam.gmiContainer
      {
      import flash.utils.*;

      import mx.collections.ArrayCollection;

      [Bindable]
      [RemoteClass(alias="handjam.gmiContainer.GMIContainer")]
      public class GMIContainer
      {
      private var _dataObjects:ArrayCollection;
      private var _methodName:String;

      public function GMIContainer()
      {
      }

      public function get dataObjects():ArrayCollection {
      return _dataObjects;
      }

      public function get methodName():String {
      return _methodName;
      }

      public function set dataObjects(dataObjects:ArrayCollection):void {
      trace("Setting the dataObject from Java = " + dataObjects);
      this._dataObjects=dataObjects;
      }

      public function set methodName(methodName:String):void {
      trace("Setting the methods Name from Java = " + methodName);
      this._methodName=methodName;
      }

      }
      }

      Code setting the List:
      GMIContainer container = new GMIContainer();
      List data = new ArrayList();
      data.add(id);
      data.add(mapItems);

      mapItems is a MapItemTypeSeq Java Type

      package mil.army.monmouth.webmap.data;

      import java.util.ArrayList;
      import java.util.List;
      import javax.xml.bind.annotation.XmlAccessType;
      import javax.xml.bind.annotation.XmlAccessorType;
      import javax.xml.bind.annotation.XmlType;


      /**
      * Array of MapItemType
      *
      * <p>Java class for MapItemTypeSeq complex type.
      *
      * <p>The following schema fragment specifies the expected content contained within this class.
      *
      * <pre>
      * &lt;complexType name="MapItemTypeSeq">
      * &lt;complexContent>
      * &lt;restriction base="{ http://www.w3.org/2001/XMLSchema}anyType">
      * &lt;sequence>
      * &lt;element name="mapItems" type="{ http://www.gmiweb.com/schema/mapdata}MapItemType" maxOccurs="unbounded" minOccurs="0"/>
      * &lt;/sequence>
      * &lt;/restriction>
      * &lt;/complexContent>
      * &lt;/complexType>
      * </pre>
      *
      *
      */
      @XmlAccessorType(XmlAccessType.FIELD)
      @XmlType(name = "MapItemTypeSeq", propOrder = {
      "mapItems"
      })
      public class MapItemTypeSeq {

      protected List<MapItemType> mapItems;

      /**
      * Gets the value of the mapItems property.
      *
      * <p>
      * This accessor method returns a reference to the live list,
      * not a snapshot. Therefore any modification you make to the
      * returned list will be present inside the JAXB object.
      * This is why there is not a <CODE>set</CODE> method for the mapItems property.
      *
      * <p>
      * For example, to add a new item, do as follows:
      * <pre>
      * getMapItems().add(newItem);
      * </pre>
      *
      *
      * <p>
      * Objects of the following type(s) are allowed in the list
      * {@link MapItemType }
      *
      *
      */
      public List<MapItemType> getMapItems() {
      if (mapItems == null) {
      mapItems = new ArrayList<MapItemType>();
      }
      return this.mapItems;
      }

      }



      Here is what the JAXWS Java class look like:

      package mil.army.monmouth.webmap.data {
      import flash.utils.*;
      import mx.collections.ArrayCollection;
      [Bindable]
      [RemoteClass(alias="mil.army.monmouth.webmap.data.MapItemTypeSeq")]

      public class MapItemTypeSeq {

      public var _mapItems:ArrayCollection;

      public function get mapItems():ArrayCollection {
      return _mapItems;
      }

      public function set mapItems(mapItems:ArrayCollection):void {
      this._mapItems=mapItems;
      }
      }
      }

      when the message comes to my client the flashlog.txt tells me something like this.

      GMIContainer => MapItemTypeSeq
      _mapItems = (null)
      mapItems = null

      Has anyone else ran into this issue with complicated data objects? All examples I have seen uses very simple
      data types.

      Thanks for your help,

      dk