在flex中从java接收对象数据类型

发布于 2024-12-21 06:55:57 字数 1037 浏览 3 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七婞 2024-12-28 06:55:57

谢谢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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文