0

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;

 }
}
Shua
  • 1,315
  • 8
  • 10

3 Answers3

0

Sending several Date objects in the same class should not be a problem.

Are you sure you don't have a small error somewhere in the getter or the setter? Do you have both a getter and a setter for the property?

Christophe Herreman
  • 15,895
  • 9
  • 58
  • 86
  • no the problem isn't the values not getting set correctly.... The issue is the value is coming from the flex as NULL – Shua Sep 30 '09 at 15:35
  • to elaborate..... lets say I put a break point in the Java class at the setEndDate funciton... when that gets executed the endDate parameters is NULL... even though it was set in the flex before sending it – Shua Sep 30 '09 at 15:39
  • did you already check with a http debugger (Charles for instance) if the date is not null when you send it out? That is before it is received on the server and parsed in BlazeDS. – Christophe Herreman Sep 30 '09 at 15:57
  • thanks for responses.... but yea my dates are going through the http debugger with the correct dates..but i check the object on the server and the cdate = null.... this leads me to believe its something in the setter like you said but I don't see what it could be – Shua Sep 30 '09 at 17:44
0

You could try:

  • Setting the logging level to debug in services-config.xml to gather more information. Described here.
  • Try custom serialization using IExternalizable. Good post here.
  • Adding TraceTarget to the application.mxml to get more debug info. Info.
  • Since the package names don't match, did you register the class alias or reference the object in the application.mxml? Here.
Brandon
  • 6,832
  • 11
  • 38
  • 50
0

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.

Shua
  • 1,315
  • 8
  • 10