MACROMEDIA COLDFUSION 5-DEVELOPING Manuale Utente Pagina 46

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 47
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 45
ColdFusion MX 7 Getting Started Experience Tutorial Page 46 of 47
Figure 65. Viewing only the
getArtwork() function in
the art CFC
Learning Point: Locating CFCs
CFCs are referenced based on their relationship to the web root of the server. In this case, you are using the built-in
ColdFusion MX 7 web server, so the directory structure is
c:\cfusionmx\wwwroot\cfide\gettingstarted\tutorial\.
The tutorial listed in the Components panel refers to the tutorial directory inside wwwroot. The word art refers to the Art.cfc
component in the tutorial directory, and the words query getArtwork() refer to the getArtwork function within the Art.cfc
component that has a return type of query.
14. Return to the index.cfm page and drag the getArtwork() function from the Components tab to the top of the
index.cfm page, where the query used to be.
Figure 66. Dragging the
getArtwork() function to
the index.cfm page
15. Review the code that is inserted.
<cfinvoke
component="CFIDE.gettingstarted.tutorial.art"
method="getArtwork"
returnvariable="getArtworkRet">
</cfinvoke>
Learning Point: the cfinvoke tag
You use the cfinvoke tag to call functions inside of CFCs. The component attribute locates the CFC based on its
relationship to the web root, just like the Components tab. Usually directories and files in paths are separated by forward
or back slashes, but when referring to a CFC, they are separated by periods and the CFC, in this case art.cfc, is listed
without its file extension.
The method attribute refers to the function in the CFC that you would like to call, in this case, getArtwork.
The returnvariable attribute of the cfinvoke tag has a similar purpose as the name attribute of a cfquery tag. It
creates and names a variable to hold all of the values returned from the CFC. By default, Dreamweaver automatically
names the variable with the method name, followed by the letters Ret, which is shorthand for the word return.
Vedere la pagina 45
1 2 ... 41 42 43 44 45 46 47

Commenti su questo manuale

Nessun commento