代码之家  ›  专栏  ›  技术社区  ›  hering Robyn Liu

Flex/mate:mate不缓存用Object Builder创建的实例

  •  2
  • hering Robyn Liu  · 技术社区  · 14 年前

    但在下面的示例中,mate似乎再次尝试实例化对象:

    出现以下错误:

    ! TerminalPresentationModel - constructor called # dispatcher = [object GlobalDispatcher] ! 
    <Injectors (started)    target="[class TerminalPresentationModel]"   includeDerivatives="false"   dispatcherType="inherit"   scope="[object Scope]">
            <PropertyInjector   sourceKey="currentDate"   targetKey="date"   source="[class DateManager]"   sourceCache="inherit"   softBinding="false"/>
    
    ---------------------------------------------------------
    - ERROR: Wrong number of arguments supplied when calling the constructor 
    - TARGET: TerminalPresentationModel 
    - TAG: PropertyInjector 
    - METHOD: constructor
    - FILE: TerminalMainEventMap
    - NO ARGUMENTS SUPPLIED 
    - STACK TRACE: ###SHORTENED###
    ---------------------------------------------------------
    
    
    ---------------------------------------------------------
    - ERROR: source is undefined in tag PropertyInjector 
    - TARGET: TerminalPresentationModel 
    - TAG: PropertyInjector 
    - FILE: TerminalMainEventMap
    ---------------------------------------------------------
    
    - INFO: Data binding will not be able to detect assignments to date
    </Injectors (end)    target=[class TerminalPresentationModel]>
    ! DateManager - constructor called # dispatcher = [object GlobalDispatcher] !
    <Injectors (started)    target="[class TerminalContainer]"   includeDerivatives="false"   dispatcherType="inherit"   scope="[object Scope]">
        <ObjectBuilder   registerTarget="true"   constructorArguments="[object GlobalDispatcher]"   cache="inherit"   generator="[class TerminalPresentationModel]"/>
        <PropertyInjector   targetKey="pm"   source="[object TerminalPresentationModel]"   sourceCache="inherit"   softBinding="false"/>
    - INFO: Data binding will not be able to detect assignments to pm
    </Injectors (end)    target=[class TerminalContainer]>
    

    我的代码有什么问题吗?

    更新2010-08-16 我使用事件图:

    <?xml version="1.0" encoding="utf-8"?>
    <EventMap
        >
    
        <fx:Script>
            <![CDATA[           
                // imports and namespaces shortened
    
                [Bindable]
                public var endpoint:String = "";
            ]]>
        </fx:Script>
    
    
        <fx:Declarations>
            <Debugger level="{Debugger.ALL}" />
    
            <myService:Services id="services" endpoint="{endpoint}"/>
    
            <maps:TimeEventMap endpoint="{endpoint}"/>
    
            <EventHandlers type="{FlexEvent.PREINITIALIZE}">
                <ObjectBuilder 
                    generator="{TerminalPresentationModel}" 
                    constructorArguments="{scope.dispatcher}" />
                <ObjectBuilder
                    generator="{DateManager}"
                    constructorArguments="{scope.dispatcher}" />
                <ObjectBuilder
                    generator="{TerminalFaultHandler}" />
            </EventHandlers>
    
            <EventHandlers type="{DataServiceEvent.GET_CURRENT_TERMINAL_STATUS}">
                <RemoteObjectInvoker instance="{services.TerminalService}"
                     method="getCurrentTerminalStatus"
                     arguments="{[event.locationId,event.actualPlan]}"
                     showBusyCursor="false">
                    <resultHandlers>
                        <MethodInvoker generator="{TerminalPresentationModel}"
                                       method="setCurrentTerminalStatus"
                                       arguments="{resultObject}" />
                        <MethodInvoker generator="{TerminalFaultHandler}"
                                       method="removeError" />
                    </resultHandlers>
                </RemoteObjectInvoker>
            </EventHandlers>
    
    
            <Injectors target="{TerminalContainer}"
                       debug="true">
                <ObjectBuilder
                    generator="{TerminalPresentationModel}"
                    constructorArguments="{scope.dispatcher}" />
                <PropertyInjector
                    targetKey="pm"
                    source="{lastReturn}" />
            </Injectors>
    
            <Injectors target="{TerminalPresentationModel}"
                       debug="true">
                <PropertyInjector targetKey="date" source="{DateManager}" sourceKey="currentDate" />
            </Injectors>
    
            <Injectors target="{TerminalContent}">
                <PropertyInjector targetKey="faultHandler"
                    source="{TerminalFaultHandler}" />
            </Injectors>
    
            <EventHandlers type="{UnhandledFaultEvent.FAULT}">
                <MethodInvoker generator="{TerminalFaultHandler}" method="handleFault" 
                               arguments="{event.fault}" />
            </EventHandlers>
        </fx:Declarations>
    </EventMap>
    

    配合:0.8.9

    2 回复  |  直到 14 年前
        1
  •  0
  •   ktutnik    14 年前

    debug="true" 在EventHandlers和Injector标记中,看一看前面哪个。。尝试组合CreationComplete事件,而不是预先初始化。如果我在应用程序创建中没有弄错的话,那么complete比Preinitialize早(但我不确定。。因为我也很困惑)。

        2
  •  0
  •   hering Robyn Liu    14 年前

    当我在Preinitialize事件中删除ObjectBuilder时,一切正常。

    这是一个奇怪的行为,因为在其他地方,我写它像在这种情况下,没有问题发生。