我在我的基于Web的应用程序Flex 3.6(使用BlazeDS)上发生了错误,没有错误。我试着描述我的问题:我有一个java类:
public class User {...}
和.as中的绑定:
[Bindable]
[RemoteClass(alias="it.dto.User")]
public class User {...}
我还有一个DataManager.as来做这样的异步调用:
public function getUser():void {
var token:AsyncToken = _service.getUser();
token.addResponder(new AsyncResponder(userOnResult,userOnFault));
}
private function userOnFault(event:FaultEvent,token:Object):void {
var _fail:String = "Error";
}
private function socOnResult(event:ResultEvent,token:Object):void {
_resUser = event.result as ArrayCollection;
dispatchEvent(new MyEvent("USER_EVENT",_resUser));
}
现在我在两个不同的.as文件(不同的包)中实现了以下代码,它引用了两个不同的.mxml:
var data:DataManager = new DataManager;
....
data.addEventListener("USER_EVENT",userResult);
....
data.getUser();
....
private function userResult(dataEvent:MyEvent):void {
var user:ArrayCollection = new ArrayCollection;
user = dataEvent.result as ArrayCollection;
for (var i:int = 0;i<user.length; i++) {
var u:User = new User;
u = (User)(user.getItemAt(i));
}
_dm.removeEventListener("USER_EVENT",userResult);
}
戏剧是第一个。它完美地运作,而在第二个。它给我一个强制错误失败。在第二个文件中似乎无法识别User类。 你有什么主意吗??我疯了! 谢谢
@Stacktrace错误:
TypeError: Error #1034: Type Coercion failed: cannot convert appcode.dto::SocietaDTO@b4dbfc1 to appcode.dto.SocietaDTO.
at modules::ReportIspezioni/onSocResult()[D:\workspace\maga\aga\flex_src\modules\ReportIspezioni_src.as:80]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at appcode.dao::DataManager/socOnResult()[D:\workspace\maga\aga\flex_src\appcode\dao\DataManager.as:180]
at mx.rpc::AsyncResponder/result()[C:\autobuild\3.x\frameworks\projects\rpc\src\mx\rpc\AsyncResponder.as:82]
at mx.rpc::AsyncToken/http://www.adobe.com/2006/flex/mx/internal::applyResult()[C:\autobuild\3.x\frameworks\projects\rpc\src\mx\rpc\AsyncToken.as:199]
at mx.rpc.events::ResultEvent/http://www.adobe.com/2006/flex/mx/internal::callTokenResponders()[C:\autobuild\3.x\frameworks\projects\rpc\src\mx\rpc\events\ResultEvent.as:172]
at mx.rpc::AbstractOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[C:\autobuild\3.x\frameworks\projects\rpc\src\mx\rpc\AbstractOperation.as:199]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[C:\autobuild\3.x\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:263]
at mx.rpc::Responder/result()[C:\autobuild\3.x\frameworks\projects\rpc\src\mx\rpc\Responder.as:46]
at mx.rpc::AsyncRequest/acknowledge()[C:\autobuild\3.x\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:74]
at NetConnectionMessageResponder/resultHandler()[C:\autobuild\3.x\frameworks\projects\rpc\src\mx\messaging\channels\NetConnectionChannel.as:524]
at mx.messaging::MessageResponder/result()[C:\autobuild\3.x\frameworks\projects\rpc\src\mx\messaging\MessageResponder.as:199]
很可能上面写的User类只是为了理解代码逻辑。真正的类是DTO调用SocietaDTO。 N.B:代码在我项目的另一个模块中完美运行..我不明白为什么在这里它不起作用。
非常感谢
答案 0 :(得分:0)
我在开发时从不保存浏览器缓存..无论如何,我通过添加以下内容来解决问题:
registerClassAlias("it.mec.dto.SocietaDTO", SocietaDTO);
在课堂上发布异常。
非常感谢