简体   繁体   English

深度灵活加载值对象的问题(前端的延迟加载?)

[英]Problems with indepth flex loading of value objects (Lazy loading at the front-end?)

I'm using a java-backend with a flex frontend. 我正在使用带有Flex前端的Java后端。 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. 当我想使用labelfunction时,它不会加载诸如value对象之类的深入属性,就像是在flex端延迟加载一样,我确定它不是从后端来的,因为我已经检查了它在那边。

I've got it also in datagrid's that it doesn't load all the values at once. 我在datagrid中也得到了它,它不会一次加载所有值。

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. 现在在flex端,当我接收到数据时,我会从callresponder中触发结果事件。 But still it can't acces the doe's into the Johns, the doe property of john is still null. 但是仍然不能让美国能源部加入约翰斯,约翰的doe属性仍然为空。 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 招呼

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. 使用BlazeDS时要记住的一件事是,通过网络发送的类被序列化和反序列化。 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. 您必须密切注意Java端和Flex端的类中的基本数据类型。 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. 我所说的“明确”是,当BlazeDS无法弄清楚哪个变量应该放在哪里时,就会感到困惑。

Although your Doe class is not a String, it only contains a string. 尽管您的Doe类不是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. 对您来说,John包含“ Doe”和一个字符串,但最终BlazeDS真正看到的只是一个字符串和一个字符串。

Just to test, in your basic example, change Doe.lastName to an Integer or some other object. 为了测试,在您的基本示例中,将Doe.lastName更改为Integer或其他对象。 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. 如果仍然为null,则您的ActionScript和Java类(John和Doe)不正确匹配,或者它们太含糊。

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. BlazeDS无法弄清楚如何读取写入网络的内容。 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 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架构...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM