在弹出窗口中加载数据时出现错误。
错误 :-
TypeError:错误 #1034:类型强制失败:无法将 flash.events::Event@bcb8291 转换为 mx.events.CloseEvent。在 flash.events::EventDispatcher/dispatchEventFunction() 在 flash.events::EventDispatcher/dispatchEvent() 在 mx.core::UIComponent/dispatchEvent() 在 com.nxp.pcn.modules.avl.view::AvlMediator/onAutoConfirmUploadPtaFile ()[D:\ravi\new_latest\ePCN\Application\src\main\flex\com\nxp\pcn\modules\avl\view\AvlMediator.as:219] 在 flash.events::EventDispatcher/dispatchEventFunction() 在flash.events::EventDispatcher/dispatchEvent() at mx.core::UIComponent/dispatchEvent() at com.nxp.pcn.modules.avl.view.components.popups::AvlUploadPopup/set stats()[D:\ravi \new_latest\ePCN\Application\src\main\flex\com\nxp\pcn\modules\avl\view\components\popups\AvlUploadPopup.mxml:138] 在 com.nxp.pcn.modules.avl.view::http://adobe.com/AS3/2006/builtin::apply() 在 org.puremvc.as3.multicore.patterns.observer::Observer/notifyObserver()[C:\Documents and Settings\Owner\My Documents\workspaces\PureMVC\PureMVC_AS3_MultiCore\src\org\puremvc\as3\multicore\patterns\ Observer\Observer.as:100] at org.puremvc.as3.multicore.core::View/notifyObservers()[C:\Documents and Settings\Owner\My Documents\workspaces\PureMVC\PureMVC_AS3_MultiCore\src\org\puremvc\ as3\multicore\core\View.as:114] 在 org.puremvc.as3.multicore.patterns.facade::Facade/notifyObservers()[C:\Documents and Settings\Owner\My Documents\workspaces\PureMVC\PureMVC_AS3_MultiCore\ src\org\puremvc\as3\multicore\patterns\facade\Facade.as:294] 在 org.puremvc.as3.multicore.patterns.facade::Facade/sendNotification()[C:\Documents and Settings\Owner\My Documents\workspaces\PureMVC\PureMVC_AS3_MultiCore\src\org\puremvc\as3\multicore\patterns\facade\Facade.as:277] 在 org.puremvc.as3.multicore.patterns.observer:: Notifier/sendNotification()[C:\Documents and Settings\Owner\My Documents\workspaces\PureMVC\PureMVC_AS3_MultiCore\src\org\puremvc\as3\multicore\patterns\observer\Notifier.as:60] 在 com.nxp.pcn .modules.avl.model::AvlProxy/uploadProductsResult()[D:\ravi\new_latest\ePCN\Application\src\main\flex\com\nxp\pcn\modules\avl\model\AvlProxy.as:77] 在flash.events::EventDispatcher/dispatchEventFunction() 在 flash.events::EventDispatcher/dispatchEvent() 在 mx.rpc::AbstractOperation/\Documents and Settings\Owner\My Documents\workspaces\PureMVC\PureMVC_AS3_MultiCore\src\org\puremvc\as3\multicore\patterns\observer\Notifier.as:60] 在 com.nxp.pcn.modules.avl.model:: AvlProxy/uploadProductsResult()[D:\ravi\new_latest\ePCN\Application\src\main\flex\com\nxp\pcn\modules\avl\model\AvlProxy.as:77] 在 flash.events::EventDispatcher/dispatchEventFunction () 在 flash.events::EventDispatcher/dispatchEvent() 在 mx.rpc::AbstractOperation/\Documents and Settings\Owner\My Documents\workspaces\PureMVC\PureMVC_AS3_MultiCore\src\org\puremvc\as3\multicore\patterns\observer\Notifier.as:60] 在 com.nxp.pcn.modules.avl.model:: AvlProxy/uploadProductsResult()[D:\ravi\new_latest\ePCN\Application\src\main\flex\com\nxp\pcn\modules\avl\model\AvlProxy.as:77] 在 flash.events::EventDispatcher/dispatchEventFunction () 在 flash.events::EventDispatcher/dispatchEvent() 在 mx.rpc::AbstractOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent() 在 mx.rpc::AbstractInvoker/ http://www.adobe.com/2006/flex/mx/internal::resultHandler () 在 mx.rpc::Responder/result() 在 mx.rpc::AsyncRequest/acknowledge() 在 NetConnectionMessageResponder/resultHandler() 在 mx.messaging::MessageResponder/result()
我在这里上传代码。
包 com.nxp.pcn.modules.avl.view { 进口 com.evelopers.flex.components.placedmodule.view.components.ModulePlaceholder; 导入 mx.collections.ArrayCollection;导入 com.evelopers.flex.components.Confirmator;导入 com.nxp.pcn.modules.avl.view.components.Avl;导入 com.nxp.pcn.modules.avl.view.components.renderers.AvlPartNumberRenderer;
import com.nxp.pcn.modules.avl.view.components.popups.AvlUploadPopup;
import com.nxp.pcn.modules.avl.view.components.popups.ManageActivationPopup;
import com.nxp.pcn.shell.model.vo.AvlProductVO;
import com.nxp.pcn.modules.avl.AvlConstants;
import com.nxp.pcn.modules.avl.view.components.sf.searchAvl;
import com.nxp.pcn.shell.interfaces.IDictionaryVO;
import flash.events.Event;
import com.nxp.pcn.shell.ApplicationConstants;
import com.nxp.pcn.shell.model.SessionUserProxy;
import org.puremvc.as3.multicore.interfaces.INotification;
import org.puremvc.as3.multicore.patterns.mediator.Mediator;
import com.evelopers.flex.modules.ValueListModule;
import com.nxp.pcn.modules.avl.view.AddAvlProductMediator;
import com.nxp.pcn.modules.avl.view.ManageActivationPopupMediator;
import flash.display.DisplayObject;
import flash.utils.setTimeout;
import mx.utils.ObjectUtil;
import mx.managers.PopUpManager;
import mx.core.FlexGlobals;
import com.nxp.pcn.modules.avl.model.vo.AvlAttachmentVO;
import com.evelopers.flex.utils.PopupUtils;
import com.nxp.pcn.modules.avl.model.vo.AvlUploadStatsVO;
import com.nxp.pcn.shell.helpers.Tracer;
import com.nxp.pcn.shell.view.components.ProductDescriptionPopup;
import com.evelopers.flex.utils.PopupUtils;
import com.nxp.pcn.shell.model.SessionUserProxy;
import flash.display.DisplayObject;
import com.evelopers.flex.helpers.SmartEvent;
import flash.external.ExternalInterface;
import mx.utils.StringUtil;
import com.nxp.pcn.shell.model.vo.CompanyVO;
public class AvlMediator extends Mediator
{
public static const NAME:String = "AvlMediator";
private var _sessionUserProxy:SessionUserProxy;
private var _dicts:Object = {};
public var _productsToRemove:Array;
private var _uploadAvlPopup : AvlUploadPopup;
public var avlCompanies : ArrayCollection;
public function AvlMediator(viewComponent:Avl)
{
super(NAME, viewComponent);
}
override public function onRegister():void {
// Retrieve the proxies
_sessionUserProxy = facade.retrieveProxy(SessionUserProxy.NAME) as SessionUserProxy;
// Create and register Mediators
component.addEventListener(Avl.REJECT, onReject);
component.addEventListener(Avl.REJECT_UPLOAD, onRejectUpload);
component.addEventListener(Avl.UPLOAD, onUpload);
component.addEventListener(Avl.ADD_PRODUCT, onAddProduct);
component.addEventListener(Avl.REMOVE_PRODUCT, onRemoveProduct);
component.addEventListener(Avl.DOWNLOAD_AVL_TEMPLATE, onDownloadAvlTemplate);
component.addEventListener(Avl.MANAGE_ACTIVATION, onManageActivation);
component.addEventListener(AvlPartNumberRenderer.VIEW_PRODUCT_DETAILS, onViewProductDetails);
//component.addEventListener(ManageActivationPopupMediator.POPUP_REMOVED, onManageActivationPopupRemoved);
// Register view handlers
sendNotification(ApplicationConstants.GET_SESSION_USER);
sendNotification(ApplicationConstants.REQUEST_DICTIONARY, ApplicationConstants.dicts.CUSTOMER_ACTIVE_COMPANIES);
sendNotification(AvlConstants.GET_AVL_COMPANIES);
// register Mediators
facade.registerMediator(new AddAvlProductMediator());
facade.registerMediator(new ManageActivationPopupMediator());
}
public function get selectedOrg():CompanyVO
{
return component.selectedOrg;
}
private function onDownloadAvlTemplate(event:Event):void
{
Tracer.trace(this, sf.sessionUser, 'session user');
Tracer.trace(this, StringUtil.substitute(ApplicationConstants.urls.AVL_SPECIFIC_EXPORT_SERVLET, ApplicationConstants.valueLists.AVL_PRODUCT_TEMPLATE_VL), 'on download avl template');
ExternalInterface.call('downloadFile',
StringUtil.substitute(ApplicationConstants.urls.AVL_SPECIFIC_EXPORT_SERVLET,
ApplicationConstants.valueLists.AVL_PRODUCT_TEMPLATE_VL));
}
private function onRejectUpload(event:Event):void
{
sendNotification(AvlConstants.PRODUCTS_UPLOAD_REJECT_QUERY);
}
/*
*/
/*
private function onManageActivationPopupRemoved(e:Event):void
{
Tracer.trace(this, 'onManageActivationPopupRemoved', 'AvlMediator');
facade.removeMediator(ManageActivationPopupMediator.NAME);
}
*/
private function onUpload(e:Event):void
{
PopupUtils.addFixedPopup(uploadAvlPopup, FlexGlobals.topLevelApplication as DisplayObject, true);
uploadAvlPopup.updateView();
}
private function onManageActivation(e:Event):void
{
sendNotification(AvlConstants.ADD_MANAGE_ACTIVATION_POPUP);
/*
var detailsPopup:ManageActivationPopup = new ManageActivationPopup();
//detailsPopup.productData = event.data;
//detailsPopup.sessionUser = (facade.retrieveProxy(SessionUserProxy.NAME) as SessionUserProxy).userVO;
PopupUtils.addFixedPopup(detailsPopup, this.component, true);
*/
}
private function onViewProductDetails(event:SmartEvent):void {
var detailsPopup:ProductDescriptionPopup = new ProductDescriptionPopup();
detailsPopup.productData = event.data;
detailsPopup.sessionUser = (facade.retrieveProxy(SessionUserProxy.NAME) as SessionUserProxy).userVO;
PopupUtils.addFixedPopup(detailsPopup, event.target as DisplayObject, true);
}
public function get uploadAvlPopup():AvlUploadPopup {
if (_uploadAvlPopup == null) {
_uploadAvlPopup = new AvlUploadPopup();
_uploadAvlPopup.addEventListener(AvlUploadPopup.AUTO_CONFIRM_UPLOAD, onAutoConfirmUploadPtaFile);
_uploadAvlPopup.addEventListener(AvlUploadPopup.CONFIRM_UPLOAD, onConfirmUploadPta);
_uploadAvlPopup.addEventListener(AvlUploadPopup.REJECT_UPLOAD, onRejectUploadPta);
_uploadAvlPopup.addEventListener(AvlUploadPopup.UPLOAD_FILE, onUploadPtaFile);
var orgs:ArrayCollection = new ArrayCollection( ObjectUtil.copy(avlCompanies.source) as Array);
//orgs.removeItemAt(0);
_uploadAvlPopup.organizations = orgs;
//Tracer.trace(this, selectedOrg, 'selected org');
if (selectedOrg)
{
for each (var org : CompanyVO in _uploadAvlPopup.organizations)
{
if (org.name == selectedOrg.name)
{
setTimeout(setUploadOrg, 500, org);
}
}
}
_uploadAvlPopup.addEventListener(Event.CLOSE, function(event:Event):void
{
PopUpManager.removePopUp(_uploadAvlPopup);
sendNotification(ApplicationConstants.CP_REJECT_PTA_UPLOAD_QUERY);
_uploadAvlPopup = null;
});
}
return _uploadAvlPopup;
}
private function setUploadOrg(org:CompanyVO):void
{
_uploadAvlPopup.companyCombo.selectedItem = org;
_uploadAvlPopup.companyCombo.text = org.name;
}
private function onConfirmUploadPta(event:Event):void
{
PopUpManager.removePopUp(_uploadAvlPopup);
sendNotification(AvlConstants.PRODUCTS_UPLOAD_CONFIRM_QUERY, true);
}
private function onRejectUploadPta(event:Event):void
{
PopUpManager.removePopUp(_uploadAvlPopup);
sendNotification(AvlConstants.PRODUCTS_UPLOAD_REJECT_QUERY);
}
private function onUploadPtaFile(event:Event):void {
var att:AvlAttachmentVO = new AvlAttachmentVO();
att.companyId = _uploadAvlPopup.companyCombo.selectedItem.id;
att.fileReference = uploadAvlPopup.fileReferenceVO;
sendNotification(AvlConstants.PRODUCTS_UPLOAD_QUERY, att);
Tracer.trace(this, att, 'upload file');
}
private function onAutoConfirmUploadPtaFile(event:Event):void {
sendNotification(ApplicationConstants.INFO_MESSAGE, 'Avl file has been uploaded successfully');
sendNotification(ApplicationConstants.INFO_MESSAGE, 'A new match has been made, organization list has been re-created.');
uploadAvlPopup.dispatchEvent(new Event(Event.CLOSE));
//reloadPcn(pcnCreation.pcnVO, CreationProductsSection.NAME);
}
private function onConfirmUploadPtaFile(event:Event):void {
//sendNotification(ApplicationConstants.CP_CONFIRM_UPLOAD_PTA_QUERY, true);
}
private function onRejectUploadPtaFile(event:Event):void {
//sendNotification(ApplicationConstants.CP_CONFIRM_UPLOAD_PTA_QUERY, false);
}
private function onReject(event:Event):void
{
sendNotification(AvlConstants.PRODUCTS_REJECT_QUERY);
}
private function onAddProduct(e:Event):void
{
sendNotification(AvlConstants.AVL_ADD_PRODUCT_POPUP);
}
private function onRemoveProduct(e:Event):void
{
var fullData:ArrayCollection = avl.vlStateData.fullData;
_productsToRemove = []; // <AvlProductVO>
for each (var record : Object in fullData)
{
if (record['isSelected'])
{
_productsToRemove.push(new AvlProductVO(uint(record['companyId']), record['nc12']));
}
}
if (_productsToRemove.length == 0) return;
if (fullData.length == _productsToRemove.length && _productsToRemove.length > 1)
{
// Gonna delete ALL distributors
new Confirmator('Remove Products confirmation',
'You are about to remove ALL products\nPress "OK" to proceed',
Confirmator.OK_CANCEL, removeAllProducts);
} else {
new Confirmator('Remove Products confirmation',
'You are about to remove ' + _productsToRemove.length + ' product(s)\nPress "OK" to proceed',
Confirmator.OK_CANCEL, removeProducts);
}
}
private function removeProducts(event:Event):void
{
sendNotification(AvlConstants.AVL_REMOVE_PRODUCTS_QUERY, _productsToRemove);
_productsToRemove = null;
}
private function removeAllProducts(event:Event):void
{
sendNotification(AvlConstants.AVL_REMOVE_PRODUCTS_QUERY);
}
override public function listNotificationInterests():Array
{
return [
ApplicationConstants.RESPONSE_DICTIONARY,
AvlConstants.PRODUCTS_ADD_CONFIRMED,
AvlConstants.PRODUCTS_ADD_CONFIRMED_RESULT,
AvlConstants.PRODUCTS_REJECT_QUERY,
AvlConstants.PRODUCTS_DELETED,
AvlConstants.PRODUCTS_UPLOAD_QUERY_RESULT,
AvlConstants.PRODUCTS_UPLOAD_CONFIRMED,
AvlConstants.PRODUCTS_UPLOAD_QUERY_FAULT,
AvlConstants.GET_AVL_COMPANIES_RESULT
];
}
override public function handleNotification(note:INotification):void
{
switch (note.getName())
{
case ApplicationConstants.RESPONSE_DICTIONARY:
var dict:IDictionaryVO = note.getBody() as IDictionaryVO;
switch (dict.getName())
{
case ApplicationConstants.dicts.CUSTOMER_ACTIVE_COMPANIES:
_dicts[ApplicationConstants.dicts.CUSTOMER_ACTIVE_COMPANIES] = dict;
sf.organizations = dict.filter;
break;
}
break;
case AvlConstants.PRODUCTS_UPLOAD_QUERY_RESULT:
validateUploadedProducts(note);
break;
case AvlConstants.PRODUCTS_UPLOAD_QUERY_FAULT:
PopUpManager.removePopUp(_uploadAvlPopup);
break;
case AvlConstants.GET_AVL_COMPANIES_RESULT:
//Tracer.trace(this, note.getBody(), 'GET_AVL_COMPANIES_RESULT');
avlCompanies = ArrayCollection(note.getBody());
if(avlCompanies.length > 0){
avl.hasAvlCompanies = true;
}
break;
case AvlConstants.PRODUCTS_UPLOAD_CONFIRMED:
case AvlConstants.PRODUCTS_ADD_CONFIRMED_RESULT:
case AvlConstants.PRODUCTS_ADD_CONFIRMED:
avl.vlSearchAvl.dispatchEvent(new Event(ValueListModule.DO_SEARCH));
break;
case AvlConstants.PRODUCTS_DELETED:
sendNotification(ApplicationConstants.INFO_MESSAGE, 'Avl product(s) were removed successfully');
avl.vlSearchAvl.dispatchEvent(new Event(ValueListModule.DO_SEARCH));
break;
}
}
private function validateUploadedProducts(note:INotification):void
{
var stats : AvlUploadStatsVO = AvlUploadStatsVO(note.getBody());
uploadAvlPopup.stats = stats;
if (!uploadAvlPopup.isAutoConfirm())
{
PopupUtils.addFixedPopup(uploadAvlPopup, component, true);
}
}
public function insertUI(placeholder:ModulePlaceholder):void
{
component.sessionUser = _sessionUserProxy.getSessionUser();
if (!component.sessionUser) {
return;
}
placeholder.addChild(component);
}
private function get component():Avl
{
return viewComponent as Avl;
}
private function get avl():Avl
{
return component;
}
private function get sf():searchAvl
{
return component.sf;
}
public function getCurrentOrg():int
{
if (sf.searchFilter.obj.companyId == null)
{
return -1;
} else
{
return sf.searchFilter.obj.companyId.id;
}
}
}
}
请让我知道问题出在哪里以及如何解决。
问候,拉维