2009-10-19 33 views
3

在CF9 DOC:Defining components and functions in CFScript,它說:如何在CFscript中指定參數屬性? (CF9)

/** 
*Comment text, treated as a hint. 
*Set metadata, including, optionally, attributes, in the last entries 
*in the comment block, as follows: 
*@metadataName metadataValue 
... 
*/ 
access returnType function functionName(arg1Type arg1Name="defaultValue1" 
arg1Attribute="attributeValue...,arg2Type 
arg2Name="defaultValue2" arg2Attribute="attributeValue...,...) 
functionAttributeName="attributeValue" ... { 
body contents 
} 

如何指定arg1Attribute?我試過這個:

public void function setFirstname(string firstname="" displayName="first name"){} 

但它不工作。

另外,你如何將其轉換爲腳本樣式?

<cffunction name="setPerson"> 
    <cfargument name="person" type="com.Person"/> 
</cffunction> 

我想:

function setPerson(com.Person person){} 

,它也不管用。 「你不能在這個上下文中使用」。「運算符的變量引用」它說。

+1

如果這是一個錯誤,請投票:http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html#bugId=80394 – Henry 2009-10-20 00:11:24

回答

1

固定在CF9更新1

/** This is setPerson function hint 
* @person this is person argument hint 
*/ 
function setPerson(com.Person person){} 

這是可行的,但CFBuilder(1.0版本的)仍然會考慮這個無效。

+0

你是否通過這種方式獲得代碼幫助? AKA Intellisense – jfrobishow 2010-04-14 21:21:03

+0

一旦你使用參數類型的點,CFBuilder 1.0甚至不會執行語法高亮...更不用說intellisense了 – Henry 2010-04-15 00:09:33

6

原來這是一個文檔錯誤。沒有辦法爲腳本塊中的參數提供元數據。你可以做提示,要求,類型和默認值,但沒有別的。我在問關於com.Person的事情。馬克曼德爾建議導入COM並只使用Person。

+0

Thx。我嘗試導入並使用Person,但這也不起作用,因爲該函數仍會假定參數類型是Person在同一個包中。 – Henry 2009-10-20 17:39:56

0

我剛碰到相同的問題,發現你可以用一個*做多個COM的Java風格導入。

import Path.To.Your.CFC.*; 

然後我能夠使用普通的ArgType。你可能想確保你的CF Admin中禁用了「組件緩存」,或者重新啓動服務器,因爲我非常確定CF會記得找不到它。

導入甚至「存活」3級繼承,並且可以在子組件中使用。