Valy, I would add some trace statements into your ActionScript code around these lines:
 
           addr.individual = ModelLocator._individual; // _individual gets loaded when app is initializes.
           ModelLocator._individual.physicalAddresses.push(addr);
I would double check that the individual on the ModelLocator is populated as expected before sending it over the wire.
 
It doesn't appear to be related to this case based on the code you've provided, but note that objects are deserialized on the client by the Flash player in a special order -  an object's fields are set before the constructor is invoked (so that you can have access to them in the constructor) so one has to be careful not to re-initialize them on constructing a new instance. Also be careful of relying on references on the client when round tripping instances as while it sounds obvious it can be sometimes easy to forget to update a client instance with the returned value before using it further.
 
 
 
 


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Valy Sivec
Sent: Thursday, January 05, 2006 4:05 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Flex 1.5: AS2 serialization issue . Parent/Child data model implementation


Hello Flexcoders, here I am again...
 
I have set the logging level to Debug in the gateway-config.xml and was able seeing how data is sent on the wire.... However, I wasn't able to figure out what's wrong with the code.

I have pasted below the JAVA/AS2 data model and also the AMF log messages. If you can help me would be fantastic. I'm puzzled by the fact that the Individual object is serialized correctly and not the same happens with the PhysicalAddress( Individual's child object )

Thanks in advance,
Valy

  1) JAVA DATA MODEL PARENT / CHILD  ( one to many relation )
 
  public class Individual implements Serializable {
   
        /** identifier field */
        private long indiId;
       
        /** persistent field */
        private Set PhysicalAddresses; // implemented 1 - many relation
                 
        /** default constructor */
        public Individual() {
        }
          
        public long getIndiId() {
            return this.indiId;
        }
   
        public void setIndiId(long indiId) {
          &nb! sp; this.indiId = indiId;
        }
   
        public Set getPhysicalAddresses() {
            return this.PhysicalAddresses;
        }
   
        public void setPhysicalAddresses(Set PhysicalAddresses) {
            this.PhysicalAddresses = PhysicalAddresses;
        }
         
        public String toString() {
          
            return new ToStringBuilder(this)
                .append("indiId", getIndiId())
                .toString();
           
        }
   
        public boolean equals(Object other) {
            if ( !(other instanceof Individual) ) return false;
            Individual castOther = (Individual) other;
            return new EqualsBuilder()
                .append(this.getIndiId(), castOther.getIndiId())
                .isEquals();
        }
   
        public int hashCode() {
            return new HashCodeBuilder()
                .append(getIndiId())
                .toHashCode();
        }
         
  }
 
 
 HERE IS THE CHILD
 
  public class PhysicalAddress implements Serializable {
 
      /** identifier field */
      private long addrId;
     
      /** persistent field */
      private String addrAddress;
 
      /** persistent field */
      private String addrPostalCode;
 
      /** persistent field */
      private String addrCity;
        
      /** persistent field */
      private Individual Individual; // reference to the parent
 
 
      /** default constructor */
      public PhysicalAddress() {
      }
   
      public long getAddrId() {
          return this.addrId;
      }
 
      public void setAddrId(long addrId) {
          this.addrId = addrId;
      }
 
      public String getAddrAddress() {
          return this.addrAddress;
      }
 
      public void setAddrAddress(String addrAddress) {
          this.addrAddress = addrAddress;
      }
 
      public String getAddrPostalCode() {
          return this.addrPostalCode;
      }
 
    &nbs! p; public void setAddrPostalCode(String addrPostalCode) {
          this.addrPostalCode = addrPostalCode;
      }
 
      public String getAddrCity() {
          return this.addrCity;
      }
 
      public void setAddrCity(String addrCity) {
          this.addrCity = addrCity;
      }
   
      public Individual getIndividual() {
          return this.Individual;
      }
 
      public void setIndividual(Individual Individual) {
          this.Individual = Individual;
      }
             
      public String toString() {
          return new ToStringBuilder(this)
              .append("addrId", getaddrId())
              .append("addrAddress", getaddrAddress())
              .append("addrCity", getaddrCity())
              .append("indi_id", getIndividual().getIndiId())
              .toString();
      }
     
      public boolean equals(! Object other) {
          if ( !(other instanceof PhysicalAddress) ) return false;
          PhysicalAddress castOther = (PhysicalAddress) other;
          return new EqualsBuilder()
              .append(this.getaddrId(), castOther.getaddrId())
              .isEquals();
      }
 
      public int hashCode() {
          return new HashCodeBuilder()
              .append(getaddrId())
              .toHashCode();
      }
  }

 -- AS2 DATA MODEL IMPLEMENTATION
 
 1) PARENT
 
 import org.ifd.model.PhysicalAddress;
 class org.ifd.model.Individual {
 
     public static var registered:Boolean = Object.registerClass("org.ifd.model.Individual", org.ifd.model.Individual);
     public function Individual()   
     {
     }       
     public var indiId : Number;
     public var PhysicalAddresses : Array = new Array();
        
     public function toString() : String
     {      
        var msg : String = "[INDI_ID:" + indiId  + "]";                         
        return  msg;
     }
}

2) CHILD

class org.ifd.model.PhysicalAddress extends Object
{
   
    public static var regClass = Object.registerClass("org.ifd.model.PhysicalAddress", org.ifd.model.PhysicalAddress);
   
    public function PhysicalAddress(){       
    }
   
    public var addrId : Number;
    public var addrAddress : String;
    public var addrPostalCode : String;
    public var addrCity : String;
    public var Individual : org.ifd.model.Individual;
   
  &n! bsp;    
    public function toString() : String
    {
       var msg : String = "[addr_ADDRESS" + addrAddress +
                           "addr_CITY:" + addrCity +
                           "addr_ID:" + addrId
                           "]";
       return  msg;
    }
}
 
  


 
  3) Set "Debug" in the gataway-config.xml
 
  4) ADDED AN ADDRESS TO THE INDIVIDUAL OBJECT AND SAVED THE INDIVIDUAL
     DATA SENT ON THE WIRE OK; one individual with multiple addresses
 
  (Message #1 targetURI=appBusinessDelegate.saveIndividual, responseURI=/4)
    (Array #0)
      [0] = (Object #1)
        _flag = "Envelope"
        headers = (Array #2)
          [0] = (Array #3)
            [0] = "ServiceType"
            [1] = false
            [2] = "stateless-class"
        data = "" #4)
          [0] = (Typed Object #5 'org.ifd.model.Individual')
            _remoteClass = "org.ifd.model.Individual"
            PhysicalAddresses = (Array #6)
              [0] = (Typed Object #7 'org.ifd.model.PhysicalAddress')             
                addrPostalCode = "01801"
                addrAddress = "MAIN ST"
                addrId = 1987506.0
                _remoteClass = "org.ifd.model.PhysicalAddress"
                Individual = (Ref #5)
                addrCity = "WOBURN"
              [1] = (Typed Object #8 'org.ifd.model.PhysicalAddress')
                addrAddress = "newAddress"
                addrCity = "city"
                addrPostalCode = "01801"
                Individual = (Ref #5)
            indiId = 4503050.0


 5) ADDED AN ADDRESS TO THE INDIVIDUAL OBJECT AND WANNA SEND ADDRESS OBJECT
    TO THE SERVER SIDE. OBJECTS GRAPH IS NOT SERIALIZED CORRECTLY
   
      (Message #0 targetURI=appBusinessDelegate.savePhysicalAddress, responseURI=/3)
        (Array #0)
          [0] = (Object #1)
            _flag = "Envelope"
            headers = (Array #2)
              [0] = (Array #3)
                [0] = "ServiceType"
                [1] = false
                [2] = "stateless-class"
            data = "" #4)
              [0] = (Typed Object #5 'org.ifd.model.PhysicalAddress')
                phadAddress = "newAddress"
                phadCity! = "city"
                phadPostalCode = "01801"
                Individual = (Typed Object #6 'org.ifd.model.Individual')
                  _remoteClass = "org.ifd.model.Individual"
                  indiId = undefined
                  PhysicalAddresses = undefined

6) "AS2" CO! DE

         function BtnClick_saveAddress()
       {                 
           var addr : PhysicalAddress = new PhysicalAddress();          
          
           addr.addrAddress = phad_address.text;
           addr.addrCity = phad_city.text;
           addr.addrPostalCode = phad_postal_code.text;
           addr.individual = ModelLocator._individual; // _individual gets loaded when app is initializes.
          
           ModelLocator._individual.physicalAddresses.push(addr);
     
               EventBroadcaster.getInstance().broadcastEvent( AppController.EVENT_SAVE_ADDRESS, addr );            
               EventBroadcaster.getInstance().broadcastEvent( AppController.EVENT_SAVE_OR_UPDATE_INDIVIDUAL, ModelLocator._tlcIndividual );
           }    










Peter Farland <[EMAIL PROTECTED]> wrote:
Try changing the AMF Gateway logging level from "Error" to "Debug" in the /WEB-INF/flex/gateway-config.xml file and restarting the web app.
 
The default logger implementation uses System.out to trace information to the console. Depending on your app server and how you start the process, this may appear on the command line or in a log file.
 
 


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Valy Sivec
Sent: Wednesday, January 04, 2006 3:30 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Flex 1.5: AS2 serialization issue . Parent/Child data model implementation

Peter, thanks for the message. I' got caught doing other stuff for now but I'll give it a try afternoon.

Is there any way I can see what gets sent on the wire other than dumping the value object in the log?


Thanks,
Vali


Yahoo! DSL Something to write home about. Just $16.99/mo. or less

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




YAHOO! GROUPS LINKS




Reply via email to