MACROMEDIA COLDFUSION 4.5-CFML LANGUAGE Manuale Utente Pagina 39

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 44
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 38
39Returning Structures from CFX Tags
Returning Structures from CFX Tags
As you probably already know, ColdFusion supports a feature referred to in the documentation as
Smart Structs. The idea behind the Smart Structs feature is to make it easier to construct complex
data structures in CFML code. Basically, if you use
<cfset> or some other mechanism to create a
variable, and the variable name contains dots or square brackets such that the new variable would be
nested within a structure of structures, ColdFusion will automatically create any intermediary
structures necessary to allow the
<cfset> to execute without errors.
To illustrate, consider the following line:
<CFSET OrangeWhip.Actresses.HotList.July = “Belinda Foxile”>
This line will execute successfully even if the OrangeWhip structure does not exist yet. The same goes
for the
Actresses or HotList parts.
CFX Tags Are Smart, Too
So what does this have to do with CFX tags? It turns out that the CFX interface uses the same
internal functions within the ColdFusion server to set variables. So, if you supply a variable name
that contains dots to
response.setVariable() (in Java) or Request->SetVariable() (in C++),
ColdFusion will automatically create the intermediary structures needed to set the variable with
the name you specify.
For instance, the code listings for this chapter include a file called Request2.cpp, which contains the
source code for a new CFX tag called
<CFX_ComputeStatistics>. This listing is very similar to the
<CFX_ComputeStandardDeviation> tag created earlier in this chapter and takes the same attributes.
The difference is that instead of returning a single number, it returns a structure with five keys (values)
,
named StandardDeviation, Variance, Mean, Sum, and Count (the number of non-null data points).
Figure 30.11
CFX tags can include
debugging messages if
unexpected conditions
arise.
Vedere la pagina 38
1 2 ... 34 35 36 37 38 39 40 41 42 43 44

Commenti su questo manuale

Nessun commento