簡體   English   中英

為什么在 Coldfusion 中不能順序調用同一個組件的兩個方法?

[英]why is it not possible to call two methods of the same component sequentially in Coldfusion?

所以,我幾乎整夜都在追逐一個錯誤......找到了它,但不知道出了什么問題。

我在Coldfusion中有腳本,它會發送兩封電子郵件。 cfinvoke郵件都在一個郵件程序腳本中,我用cfinvoke調用它, cfinvoke所示:

<cfinvoke component="form_mailer_basket" method="msg_order_seller"> 
... parameters
</cfinvoke>

<cfinvoke component="form_mailer_basket" method="msg_order_retailer">
... parameters
</cfinvoke>

兩個郵件參數都可以,但是第二個郵件程序拋出錯誤:

mailer orders 
************************************************************************************ 

type: Application 
************************************************************************************ 

message: Could not find the ColdFusion Component or Interface form_mailer_basket. 
************************************************************************************ 

detail: Ensure that the name is correct and that the component or interface exists. 
************************************************************************************ 

題:
誰能告訴我為什么當上面 5 行的第一個腳本可以時,第二封郵件找不到組件?

謝謝!

編輯
這是我調用這兩種方法的代碼:

<cfif new_mail.recordcount GT 0>
    <cfloop query="new_mail">
        <cfset variables.newMail = new_mail.email_bestelleingang>
            <cfinvoke component="form_mailer_basket" method="msg_order_seller"> 
                <cfinvokeargument name="delDate" value="#variables.liefdatum_mail#"/>
                <cfinvokeargument name="delMsg" value="#variables.bestell_text_mail#"/>
                <cfinvokeargument name="delOrd" value="#LOCAL.Basket.bestelltyp#"/>
                <cfinvokeargument name="mailto" value="#variables.newMail#"/>
                <cfinvokeargument name="client" value="#LOCAL.Basket.re_firma#"/>
                <cfinvokeargument name="rebate" value="#variables.kopf_rabatt#"/>
                <cfinvokeargument name="sellerIln" value="#variables.iln_verkaeuferNEU#"/>
                <cfinvokeargument name="ordNo" value="#variables.bestellnummer_neu#"/>
            </cfinvoke> 
    </cfloop>
</cfif>

...

 <cfloop query="active_check">
      <cfif active_check.freigeschaltet NEQ "1" AND active_check.freigeschaltet NEQ "0">
           <cfinvoke component="form_mailer_basket" method="msg_order_retailer">
                <cfinvokeargument name="delDate" value="#variables.liefdatum_mail#" />
                <cfinvokeargument name="delOrd" value="#LOCAL.Basket.bestelltyp#" />
                <cfinvokeargument name="mailto" value="#variables.cusMail#" />
                <cfinvokeargument name="client" value="#order_recipients.firma#" />
                <cfinvokeargument name="rebate" value="#variables.kopf_rabatt#" />
                <cfinvokeargument name="sellerIln" value="#variables.iln_verkaeuferNEU#" />
                <cfinvokeargument name="ordNo" value="#variables.bestellnummer_neu#" />
                <cfinvokeargument name="total" value="#variables.gesamtsumme#" />
                <cfinvokeargument name="menge" value="#variables.gesamtmenge#" />
                <cfinvokeargument name="curr" value="#variables.waehrung#" />
                <cfinvokeargument name="agentF" value="#variables.agentFirma#" />
               <cfinvokeargument name="agentN" value="#variables.agentName#" />
            </cfinvoke>
         </cfif>
    </cfloop>

第一個有效,第二個無效。 方法名稱正確,所有參數都可以(我知道我應該使用 argumentsColletion...),所以我一無所知,需要小睡一下。 稍后回來查看!

和 cfc:

<cfcomponent output="false" hint="basket mailing cfc - sends out all basket related mail messages">

    <!--- LOAD LANGUAGES --->
    <cfinclude template="../templates/tmp_lang.cfm">

    <!--- INIT --->
    <cffunction name="Init" access="public" returntype="any" output="false" hint="Initialize">

        <!--- nothing here for now --->

        <cfreturn true />
    </cffunction>

    ... msgs like this:

    <!--- NEW ORDER SELLER --->
    <cffunction name="msg_order_seller" access="public" output="false" hint="msg for new orders"> 
        <cfargument name="delDate" type="date" required="true" hint="delivery date" />
        <cfargument name="delMsg" type="string" required="true" hint="text message by retailer" />
        <cfargument name="delOrd" type="string" required="true" hint="order type pre/asap" />
        <cfargument name="mailto" type="string" required="true" hint="email adress" />
        <cfargument name="client" type="string" required="true" hint="buyer" />
        <cfargument name="rebate" type="string" required="true" hint="rebate 1/0" />
        <cfargument name="sellerIln" type="string" required="true" hint="seller ILN" />
        <cfargument name="ordNo" type="string" required="true" hint="order number" />

        <cfprocessingdirective suppresswhitespace="No">
            <cfmail
                    TO="#mailto#"
                    FROM="automailer@..."
                    SERVER="mail.bbb.de"
                    USERNAME="ddd"
                    PASSWORD="123456"
                    SUBJECT="#tx_automailer_order_new# - #client#">
#tx_automailer_default_anrede#

#tx_automailer_order_info#

#tx_automailer_order_type#: #ordertype# #rebateTxt#
#tx_automailer_order_del#: #deliveryDate#

#tx_automailer_order_no#:     #ordNo#
#tx_automailer_order_date#:      #DateFormat(now(),"dd.Mm.yyyy")#

#tx_kaeufer#:            #client#
#tx_automailer_order_msg#:
#delMsg#

#tx_automailer_order_iln#:  #sellerIln#

#tx_automailer_default_gruss#
#tx_automailer_default_team#
-------------
#tx_automailer_default_disclaimer#
                    </cfmail>
              </cfprocessingdirective>      
          <cfreturn />
    </cffunction>  
    ...

 </cfcomponent>     

如果你只是想解決你的問題而不是試圖找出導致它的原因,我有一個建議。 不要對同一組件多次使用 cfinvoke 標記,而是使用 cfobject 或 CreateObject() 來創建它的一個實例。 然后直接調用方法。

即使您確實采用了當前的工作方法,它也會比我的建議慢。 每次調用 cfinvoke 時都會創建一個對象,這需要處理時間。

您確定這兩種方法都存在並且是公開的嗎?

  1. 在 cfc 中使用 cfinclude不是一個好習慣,盡管我有時也不得不這樣做。
  2. 您的錯誤Could not find the ColdFusion Component or Interface form_mailer_basket似乎暗示組件本身發生了某些事情-我懷疑它與您在Init()方法中的 return 語句有關。
  3. 在 CF 的早期版本中(我認為版本 6/7 可能是 8),您可以通過在 cfc 中設置同名變量來覆蓋您的函數。 您沒有提到您正在運行的 CF 版本。

暫無
暫無

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

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