我正在使用带有 Flex 前端的 java 后端。当我想使用标签函数时,它不会加载深入的属性,例如值对象,就像它在柔性端延迟加载一样,我确信它不是来自后端,因为我已经检查过它在那边。
我在数据网格中也发现它不会立即加载所有值。
例如,
Class John{
var name:String;
var lastName:Doe;
}
Class Doe{
var lastName:String;
}
我要求在我的后端获取所有约翰的,后端给我所有包含美国能源部的约翰的。现在,在 Flex 端,当我收到该数据时,我会触发来自呼叫响应程序的结果事件。但它仍然无法将 doe 访问到 Johns,john 的 doe 属性仍然为空。当我第二次问它时,它现在是关于母鹿的,所以它看起来像是以前端方式延迟加载......
我做错了什么?
问候
I'm using a java-backend with a flex frontend. And when i want to use a labelfunction it doesn't load the indepth properties such as a value object, it's like it is lazy loaded in the flex side, I'm sure it is not comming from the backend because i've checked it overthere.
I've got it also in datagrid's that it doesn't load all the values at once.
for example
Class John{
var name:String;
var lastName:Doe;
}
Class Doe{
var lastName:String;
}
I ask at my back end get all John's, the backend gives me all John's which contains the Doe's. Now At the flex side I fire the result event from the callresponder when i receive that data. But still it can't acces the doe's into the Johns, the doe property of john is still null. When i ask it the second time it nows about the doe's, so it looks like lazy loading in a front-end way...
What am i doing wrong?
Greets
发布评论
评论(2)
完全理解你的问题是很困难的。然而,我曾经多次遇到过这样的问题。所以我得到了普遍的问题。
使用 BlazeDS 需要记住的一件事是,通过网络发送的类是序列化和反序列化的。简而言之,这意味着通过网络写入和读取的唯一内容是每个类的字段/属性。您必须密切注意 Java 端和 Flex 端类中的基本数据类型。确保所有属性/字段和公共 getter/setter 匹配并确保它们清晰。
我所说的“清晰”是指,当 BlazeDS 无法弄清楚将哪些变量粘贴在哪里时,它会感到困惑。
虽然您的 Doe 类不是 String,但它只包含一个字符串。因此,当它通过网络发送时,它看起来就像一个字符串。在这种情况下,我见过火焰变得混乱。它看到网络上有两个字符串,但它无法弄清楚哪个字符串去了哪里。对你来说,John 包含“Doe”和一个字符串,但最终 BlazeDS 真正看到的只是一个字符串和一个字符串。
只是为了测试,在您的基本示例中,将 Doe.lastName 更改为 Integer 或其他对象。很有可能,它在另一端将不再出现空值。如果它仍然为空,那么您的 ActionScript 和 Java 类 (John & Doe) 不正确匹配或者它们太不明确。
基本点是:当您接收数据时,如果结果为空,则意味着序列化存在问题。 BlazeDS 无法弄清楚如何读取写入网络的内容。因此,要么调整您的字段、属性和公共 getters/setters...,要么编写您自己的方法来序列化您的对象。
本页详细介绍了 blazeds 序列化(以及如何自行处理):
http://livedocs.adobe.com/blazeds/1/blazeds_devguide/help.html?content=serialize_data_2.html
一旦我完全理解了这一点,我的错误就会少得多种类。
希望有帮助,
-kg
It's tricky to completely understand your question. However, I've had problems along these lines, many, many times. So I get the general problem.
One thing to remember with BlazeDS is that the classes sent over the network are serialized and deserialized. Meaning, in simplified terms, that the only things written and read over the network are the fields/properties of each class. You have to pay CLOSE attention to the basic data types in your classes on both the java side and the Flex side. Make sure all properties/fields and public getters/setters match and make sure they're clear.
What I mean by "clear" is, BlazeDS gets confused when it can't figure out which variables to stick where.
Although your Doe class is not a String, it only contains a string. So, when it's sent over the network, it looks just like a string. In cases like this, I've seen the blazeds get confused. It sees two strings come over the network and it can't figure out which goes where. To you, John contains "Doe" and a String but all BlazeDS really sees, in the end, is a String and a String.
Just to test, in your basic example, change Doe.lastName to an Integer or some other object. Chances are, it will stop coming up null on the other end. If it's still null, then your ActionScript and Java classes (John & Doe) don't match properly or they're too ambiguous.
The basic point is: when things come up null when you receive data, that means you have a problem with serialization. BlazeDS can't figure out how to read what was written to the network. So either adjust your fields, properties and public getters/setters.... or write your own method for serializing your objects.
This page describes blazeds serialization (and also how to handle it on your own) in GREAT detail:
http://livedocs.adobe.com/blazeds/1/blazeds_devguide/help.html?content=serialize_data_2.html
Once I fully understood this, I had far fewer errors of this kind.
Hope that helps,
-kg
好吧,我仍然不知道为什么这样做,但我已经通过使用平面 dto 解决了它,现在我正在使用完整的 MVC 架构......
Ok i still don't know why it did that, but i've solved it by using flat dto's, now i'm using a complete MVC architecture...