在flex中从java接收对象数据类型
我正在使用 java/blazeds/flex。所以基本上我在java中有方法:
public ArrayList<Employee> getAllEmployees(){
...
ArrayList<Employee> employees = new ArrayList<Employee>();
pst = JavaConnection.getConnection()
.prepareStatement("select * from employee order by lastname");
rs = pst.executeQuery();
while (rs.next()){
Employee employee = new Employee();
employee.setId(rs.getInt("id"));
employee.setFirstName(rs.getString("firstName"));
employee.setLastName(rs.getString("lastName"));
employees.add(employee);
}
...
return employees;
}
但是在flex中从remoteobject结果我得到ArrayCollection,其中所有元素都是Object
数据类型,但不是Employee
。顺便说一句,我在 Flex 中也有值对象类。
[RemoteClass(alias="domain.Employee")]
public class Employee
{
public var id:int;
public var firstName:String;
public var lastName:String;
...
}
所以我不确定为什么我会得到对象数据类型。
如何解决这个问题?
希望我说得有道理,因为我不太擅长术语。
I am using java/blazeds/flex. So basically I have method in java:
public ArrayList<Employee> getAllEmployees(){
...
ArrayList<Employee> employees = new ArrayList<Employee>();
pst = JavaConnection.getConnection()
.prepareStatement("select * from employee order by lastname");
rs = pst.executeQuery();
while (rs.next()){
Employee employee = new Employee();
employee.setId(rs.getInt("id"));
employee.setFirstName(rs.getString("firstName"));
employee.setLastName(rs.getString("lastName"));
employees.add(employee);
}
...
return employees;
}
but in flex from remoteobject result i get ArrayCollection where all elements are with Object
datatype but not with Employee
. By the way I also have have value object class in flex.
[RemoteClass(alias="domain.Employee")]
public class Employee
{
public var id:int;
public var firstName:String;
public var lastName:String;
...
}
So I am not sure why I get object datatype.
How to fix this?
Hope I made some sense, because I am not very good with terminology.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
谢谢RIAstar,你是对的,它导入得很糟糕。
虽然我的模型中有
import valueobject.Employee;
但显然您还必须从值对象类创建实例变量。之后就成功了。我不明白的是为什么实例变量是必要的..用哪种方法创建它甚至都不重要。Thanks RIAstar, you were right, it was imported badly.
Though I had
import valueobject.Employee;
in my model but apparently you have to create instance variable from value object class also. After that it worked. What I don't understand is why instance variable is necessary.. it doesn't even matter in which method I create it.