Search code examples
javaapache-flexserializationblazedsremoteobject

AS3 Date not serializing to Java Date using BlazeDS


When I pass a Actionscript Value Object that contains a Date variable using BlazeDS it is not getting transferring as a java.util.Date object correctly. When the setBaseDatefunction gets called on the Java side the baseDate value is NULL. The weird thing is if I rename the variable on the Java side to private Date date; and create a public void setDate( Date date) function it works. The problem is I need to pass 2 different dates so I can't uses this work around.

Does anyone know what I'm doing wrong?

Here are my 2 classes:

AS3

package com.shua.flex.valueobjects
{

 [Bindable]
 [RemoteClass(alias='com.shua.valueObjects.myVO')]
 public class myVO
 {

  public var label:String;



  public var endDate:Date;


  public var baseDate:Date;

  public function myVO()
  {
   super();
  } 

 }
}

Java:

package com.shua.valueObjects;

import java.util.Date;



public class myVO{


 public static String NAME = "myVO";

 private String label;

 private Date endDate;

 private Date baseDate;


 public void setLabel(String label) {
  this.label = label;
 }

 public String getLabel() {
  return label;
 }

 public void setEndDate(Date endDate) {
  this.endDate= endDate;
 }

 public Date getEndDate() {
  return this.endDate;
 }

 public void setBaseDate( Date baseDate ){

  this.baseDate = baseDate;
 }

 public Date getBaseDate(){

  return this.baseDate;

 }
}

Solution

  • The problem was the static string in the java object. I guess the classes need to match exactly for the serialization to automatically work. So just removing the static name fixes the issue.