簡體   English   中英

SWIZ框架在flex spark.modules.Module中缺少PresentationModel

[英]SWIZ framework missing PresentationModel in flex spark.modules.Module

我有一個swiz應用程序,可加載swiz.modules.Module /模塊也使用Swiz。 當我從FlashBuilder運行該應用程序時,該應用程序可以正常工作。 發布版本在瀏覽器中無法正常工作。 模塊的表示模型不會注入視圖(模塊)。 Apache Flex 4.13 Flash Player 11.5任何瀏覽器

這是我的代碼

應用

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx"
           xmlns:config="swiz.conf.*"
           xmlns:swiz="http://swiz.swizframework.org"
            width="955" 
            height="600" 
            addedToStage="application1_addedToStageHandler(event)">

<fx:Script>
    <![CDATA[

        // to enable managers inside modules
        import mx.managers.CursorManager;
        import mx.managers.DragManager;
        import mx.managers.PopUpManager;
        import mx.managers.ToolTipManager;
        import mx.core.EmbeddedFontRegistry;

        private var popUpManager:PopUpManager; 
        private var dragManager:DragManager; 
        private var tooltipManager:ToolTipManager; 
        private var _cursorManager:CursorManager; 
        private var embeddedFontRegistry:EmbeddedFontRegistry;

        import swiz.pm.AppPM;

        [Inject]
        public var appPM:AppPM;

        protected function application1_addedToStageHandler(event:Event):void
        {
            appPM.viewAddedToStage();
        }
    ]]>
</fx:Script>

<fx:Declarations>
    <swiz:Swiz id="mySwiz" >
        <swiz:beanProviders>
            <config:MainApplicationBeans/>
        </swiz:beanProviders>
        <swiz:config>
            <swiz:SwizConfig viewPackages="swiz.views.*"
                             eventPackages="swiz.events.*"/>
        </swiz:config>
    </swiz:Swiz>
</fx:Declarations>

<mx:UIComponent id="modulesContainer"/>

AppController

package swiz.controllers
{
import mx.events.ModuleEvent;

import spark.modules.ModuleLoader;

import org.swizframework.controller.AbstractController;

import swiz.models.AppModel;
import swiz.pm.AppPM;

public class AppController extends AbstractController
{
    [Inject]
    public var appPM:AppPM;

    [Inject]
    public var appModel:AppModel;

    protected var modulesLoader:ModuleLoader;

    [PostConstruct]
    public function initHandler():void
    {
        modulesLoader = new ModuleLoader();
    }

    [EventHandler(event="AppPMEvent.VIEW_ADDED")]
    public function viewAddedHandler():void
    {
        appPM.addModuleLoader(modulesLoader);

        //load first module
        modulesLoader.addEventListener(ModuleEvent.READY,moduleReadyHandler);
        modulesLoader.url = appModel.firstModulePath;
    }

    protected function moduleReadyHandler(event:ModuleEvent):void
    {
        trace("module loaded but not inited yet");

    }
}

}

AppSwizConfig

<?xml version="1.0" encoding="utf-8"?>
<swiz:BeanProvider xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:swiz="http://swiz.swizframework.org" 
               xmlns:controllers="swiz.controllers.*" 
               xmlns:pm="swiz.pm.*" 
               xmlns:models="swiz.models.*" >
<!-- CONTROLLERS --> 
<controllers:AppController id="appController"/>
<!-- MODELS -->
<models:AppModel id="aappModel"/>
<!-- PM -->
<pm:AppPM id="appPM"/>

appPM

package swiz.pm
{
import flash.events.IEventDispatcher;

import spark.modules.ModuleLoader;

import swiz.events.AppPMEvent;

// application view presentation module
public class AppPM
{
    [Dispatcher]
    public var dispatcher:IEventDispatcher;

    protected var view:SwizFlexSparkModulesTest;

    [ViewAdded]
    public function viewAddedHandler(_view:SwizFlexSparkModulesTest):void
    {
        view = _view;
    }

    public function viewAddedToStage():void
    {
        var event:AppPMEvent = new AppPMEvent(AppPMEvent.VIEW_ADDED);
        dispatcher.dispatchEvent(event);
    }

    public function addModuleLoader(value:ModuleLoader):void
    {
        view.modulesContainer.addChild(value);
    }
}

}

模塊: FirstModule

<?xml version="1.0" encoding="utf-8"?>
<s:Module xmlns:fx="http://ns.adobe.com/mxml/2009" 
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:ns="http://swiz.swizframework.org"
      xmlns:conf="swiz.modules.FirstModule.swiz.conf.*"
      width="100%" 
      height="100%" >

<fx:Declarations>
    <ns:Swiz id="mySwiz" >
        <ns:beanProviders>
            <conf:FirstModuleBeans/>
        </ns:beanProviders>
        <ns:config>
            <ns:SwizConfig viewPackages="swiz.modules.FirstModule.*"
                             eventPackages="swiz.modules.FirstModule.events.*"/>
        </ns:config>
    </ns:Swiz>
</fx:Declarations>

<fx:Script>
    <![CDATA[
        import swiz.modules.FirstModule.swiz.pm.FirstModulePM;

        [Inject]
        public var pm:FirstModulePM;

        protected function btn_clickHandler(event:MouseEvent):void
        {
            trace("pm = "+pm);
            log.appendText("pm = "+pm);
        }
    ]]>
</fx:Script>

<s:VGroup width="100%" height="100%" horizontalAlign="center" verticalAlign="middle">
    <s:Label text="first module"/>
    <s:Button label="Load second module" 
              id="btn" 
              click="btn_clickHandler(event)"/>
    <s:TextArea id="log"/>
</s:VGroup>

第一個模塊swiz配置

<?xml version="1.0" encoding="utf-8"?>
<swiz:BeanProvider xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:swiz="http://swiz.swizframework.org" 
               xmlns:pm="swiz.modules.FirstModule.swiz.pm.*">
<!-- PM -->
<pm:FirstModulePM id="pm"/>

第一模塊PM(演示模型)

package swiz.modules.FirstModule.swiz.pm
{
import flash.events.IEventDispatcher;

public class FirstModulePM
{
    [Dispatcher]
    public var dispatcher:IEventDispatcher;
}

}

發布版本出現什么錯誤? 如果找不到某些類,則在構建發行版時可能會忽略它們,因為沒有鏈接到它們。 嘗試添加編譯標志 “ link-report filename ”,以查看是否所有必需的類都在其中以使您的應用程序正常工作。 更多信息檢查鏈接器依賴項

要強制鏈接它們,只需在主應用程序中將導入添加到缺少的類。 組織導入時請小心。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM