Only thing I can see is the extra space in
your [RemoteClass] which I would hope would not cause the mismatch. If you
enable the debug logs when the object is sent from the server to the client
does the log have the correct type of the Employee? It’s not maybe some
weird implementation class that extends Employee?
Matt
From:
flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Carlos Rovira
Sent: Saturday, April 15, 2006
3:59 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re:
Flex2/EJB3 integration: problems mapping Java/AS3 classes
ok, I though I should post
the Employee classes as well:
the AS3:
------
package
org.objectweb.easybeans.examples.entitybean {
[Bindable]
[RemoteClass(alias="org.objectweb.easybeans.examples.entitybean.Employee
")]
public class Employee {
public var
id:int;
public var
name:String;
}
}
------
the Java one:
/**
* EasyBeans
* Copyright (C) 2006 Bull S.A.S.
* Contact: [EMAIL PROTECTED]
*
* This library is free software; you can
redistribute it and/or
* modify it under the terms of the GNU
Lesser General Public
* License as published by the Free Software
Foundation; either
* version 2.1 of the License, or any later
version.
*
* This library is distributed in the hope
that it will be useful,
* but WITHOUT ANY WARRANTY; without even the
implied warranty of
* MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more
details.
*
* You should have received a copy of the GNU
Lesser General Public
* License along with this library; if not,
write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
MA 02111-1307
* USA
*
*
--------------------------------------------------------------------------
* $Id: Employee.java 9 2006-02-19 18:53:32Z
benoitf $
*
--------------------------------------------------------------------------
*/
package org.objectweb.easybeans.examples.entitybean;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* Define an employee with an id and a name.
* @author Florent Benoit
*/
@Entity
@Table(name = "EMPLOYEES")
public class Employee implements
java.io.Serializable {
/**
* Id for serializable
class.
*/
private static final long
serialVersionUID = -2366200007462547454L;
/**
* Id of this employee.
*/
private int id;
/**
* Name of the employee.
*/
private String name;
/**
* Gets the Id of the
employee.
* @return the id of the
employee.
*/
@Id
public int getId() {
return
id;
}
/**
* Sets id of the
employee.
* @param id the id's
employee
*/
public void setId(final int id)
{
this.id = id;
}
/**
* Sets the name.
* @param name of
employee.
*/
public void setName(final
String name) {
this.name = name;
}
/**
* Gets the name of the
employee.
* @return name of the
employee.
*/
public String getName() {
return
name;
}
/**
* Computes a string
representation of this employee.
* @return string
representation.
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Employee[id=").append(id).append(", name=").append(getName()).append("]");
return
sb.toString();
}
}
--------
Thanks again :)
On 4/16/06, Carlos Rovira < [EMAIL PROTECTED]> wrote:
Hi,
I've been getting fun this weekend integrating Flex2 with ObjectWeb's EasyBeans
(an early EJB3 container implementation).
I've been able to comunicate through remoting with stateless, stateful and
entity beans without problem, but with the last case (entity) I was trying to
map an Employee Java class to its corresponding AS3 version and I was not able
to do it. The result method working is the following (as you notice I'm using
Object and all works ok):
public function onResultGet(emp:Object):void {
result_lb.text = "Resultado: " + emp.name + "(id:" + emp.id + ")";
}
But If I try something like:
public function onResultGet(result:Object):void {
var emp:Employee = Employee(result);
//or
var emp:Employee = result as Employee;
result_lb.text = "Resultado: " + emp.name + "(id:" + emp.id + ")";
}
I get a runtime player exception with messages pointing me to a Coercion
problem or something like that.
Could anyone tell me what's the correct _expression_ to handle an Employee object
without having errors?, I know the Employee is reaching my flash client
watching the traces in my server.
Thanks in advance.
--
::| Carlos Rovira
::| http://www.carlosrovira.com
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
YAHOO! GROUPS LINKS