MACROMEDIA COLDFUSION 4.5-CFML LANGUAGE Manual do Utilizador

Consulte online ou descarregue Manual do Utilizador para Software de desenvolvimento MACROMEDIA COLDFUSION 4.5-CFML LANGUAGE. Extending ColdFusion with CFX Manual do Utilizador

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 44
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 0
IN THIS CHAPTER
What Are CFX Tags? 1
Introducing the CFX API 3
Writing CFX Tags with Java 8
Writing CFX Tags with Visual C++ 24
Generating Debug Output 38
Returning Structures from CFX Tags 39
Using CFX Tags Safely: Locking and
Thread Safety 43
Using CFX Tags with Previous Versions
of ColdFusion 44
CHAPTER
30
Extending
ColdFusion
with CFX
As you have learned in previous chapters, you have the capability to write your own custom tags, user
defined functions, and components—all using ColdFusion’s native language, CFML. It’s possible to
extend ColdFusion’s capabilities even farther with CFX tags. The main difference is that you don’t
use ColdFusion’s markup language to create the tag; rather, you use an external programming language
(Java or C++) to create the tags.
What Are CFX Tags?
You have already become familiar with CFML custom tags, which always start with <cf_>, the code
for which appears in a similarly named .cfm file. In this chapter, you’ll become familiar with tags that
start with <
cfx_>. These tags are compiled to a Dynamic Link Library (.dll) or a Java Class (.class)
file. Table 30.1 describes the differences between
<cf_> and <cfx_> tags.
Table 30.1 Quick Comparison: CFML Custom Tags Versus CFX Tags
CFML CUSTOM TAGS CFX TAGS
Start with cf_. Start with cfx_.
Written in C++ or Java.
Actual code is in a
.cfm file. Actual code is in a C++ .dll file or a Java .class file.
Can do just about anything that the language (Java or C++)
allows.
Must be registered in the ColdFusion Administrator, in a
step much like creating a data source or Verity collection.
Don’t need to be registered in
ColdFusion Administrator.
Can only do things that CFML
code can do.
Written using normal
ColdFusion tags and functions.
Vista de página 0
1 2 3 4 5 6 ... 43 44

Resumo do Conteúdo

Página 1 - ColdFusion

IN THIS CHAPTERWhat Are CFX Tags? 1Introducing the CFX API 3Writing CFX Tags with Java 8Writing CFX Tags with Visual C++ 24Generating Debug Output 38R

Página 2 - Choosing Between C++ and Java

10 CHAPTER 30 Extending ColdFusion with CFXFor instance, the tag can be called as shown in the following code snippet. The resulting messagewill incor

Página 3 - Introducing the CFX API

11Writing CFX Tags with JavaBasically, every Java CFX tag needs to be a public class that implements the CustomTag interface inthe com.allaire.cfx pac

Página 4 - Returning Variables and Text

12 CHAPTER 30 Extending ColdFusion with CFXTo compile your CFX, use javac on the command line to compile the HelloWorld.java file asshown below, adju

Página 5 - Working with Queries

13Writing CFX Tags with JavaRegistering the New TagNow that the class has been compiled and placed into ColdFusion’s lib folder, the only thing left t

Página 6 - METHOD DESCRIPTION

14 CHAPTER 30 Extending ColdFusion with CFX3. For the Tag Name field, enter the name of the tag, including the CFX_ part but withoutthe angle brackets

Página 7 - 7Introducing the CFX API

15Writing CFX Tags with JavaYo u can even catch exceptions thrown by a CFX and handle them intelligently, using <cftry> and<cfcatch>, like

Página 8 - Writing CFX Tags with Java

16 CHAPTER 30 Extending ColdFusion with CFXTable 30.11 (continued)ATTRIBUTE DESCRIPTIONdbschema Optional. The name of the database schema. Not all dat

Página 9

17Writing CFX Tags with JavaTable 30.12 (continued)ACTION DESCRIPTION COLUMNS RETURNEDGetProcedureColumns PROCEDURE_NAME, COLUMN_NAME,COLUMN_TYPEGetPr

Página 10 - Understanding the Java Code

18 CHAPTER 30 Extending ColdFusion with CFXListing 30.3 shows how these objects can be used together to create the <CFX_DatabaseMetaData>tag. Th

Página 11 - Compiling the CFX Tag

19Writing CFX Tags with JavaListing 30.3 (continued)} else if ( strAction.equalsIgnoreCase(“GetViews”) ) {String[] types = {“VIEW”};rs = dbmd.getTable

Página 12

2 CHAPTER 30 Extending ColdFusion with CFXWhen To Write (and Avoid Writing) a CFX TagGiven the choice between creating a CFX tag or creating a CFML-ba

Página 13 - Registering the New Tag

20 CHAPTER 30 Extending ColdFusion with CFXListing 30.3 (continued)// Fill the array with this ResultSet’s column names for (int col = 1; col <= rs

Página 14 - A Word on Exceptions

21Writing CFX Tags with Java The returnAsQuery() function, which accepts any Java-style ResultSet object and makesit available to the calling page as

Página 15 - Returning Query Objects

22 CHAPTER 30 Extending ColdFusion with CFXNOTEBefore this listing will work, you need to create an ODBC data source called ows that points to the ows

Página 16 - Table 30.11 (continued)

23Writing CFX Tags with JavaListing 30.4 (continued)<html><head><title>Database Metadata</title></head><body> <

Página 17 - Writing the Java Code

24 CHAPTER 30 Extending ColdFusion with CFXListing 30.4 (continued)<cfoutput query=”FilmsMetaData”><p><strong>Column: #COLUMN_NAME#&

Página 18

25Writing CFX Tags with Visual C++To install the CFX Tag Wizard, follow these steps:1. If Visual C++ is currently running, close it.2. Copy the cfxw

Página 19 - Listing 30.3 (continued)

26 CHAPTER 30 Extending ColdFusion with CFX7. Enter the name of your CFX tag, including the CFX_ part. If you wish, you may also entera description.8.

Página 20

27Writing CFX Tags with Visual C++Listing 30.5 shows the code generated by the ColdFusion Tag Wizard. In the next section, this codewill be modified to

Página 21 - 21Writing CFX Tags with Java

28 CHAPTER 30 Extending ColdFusion with CFXListing 30.5 (continued)// Output optional debug infoif ( pRequest->Debug() ){pRequest->WriteDebug( “

Página 22 - Figure 30.5

29Writing CFX Tags with Visual C++NOTEThe tag computes the population standard deviation, which means that it is most appropriate for analyzing a comp

Página 23 - Listing 30.4 (continued)

3Introducing the CFX APIAnother reason to use C++ is the fact that it is generally thought to be faster at extremely CPU-intensive tasks. However, rec

Página 24 - Getting Started

30 CHAPTER 30 Extending ColdFusion with CFXListing 30.5 (continued)// Retrieve value of VARIABLE attributeLPCSTR lpszVariable = pRequest->GetAttrib

Página 25

31Writing CFX Tags with Visual C++Listing 30.5 (continued)// Add this value to the totaldTotal += atof(thisVal);// Increment the counter of non-null v

Página 26 - Figure 30.6

32 CHAPTER 30 Extending ColdFusion with CFXListing 30.5 (continued)// case of an unexpected exception)catch( ... ){pRequest->ThrowException( “Error

Página 27 - Figure 30.8

33Writing CFX Tags with Visual C++NOTEQueries cannot be passed using any attribute name other than query; therefore, only one query can be passed to a

Página 28 - Writing the C++ Code

34 CHAPTER 30 Extending ColdFusion with CFXNOTEThe atof() function returns 0 if it encounters a string that can’t be parsed into a number. It doesn’t

Página 29 - ATTRIBUTE DESCRIPTION

35Writing CFX Tags with Visual C++5. Leave the Procedure field set to ProcessTagRequest unless you changed the name of theProcessTagRequest() function

Página 30 - Listing 30.5 (continued)

36 CHAPTER 30 Extending ColdFusion with CFXListing 30.7 (continued)---><!---Retrieve film information from database---> <cfquery datasour

Página 31

37Writing CFX Tags with Visual C++Listing 30.7 (continued)<p>Standard deviation of the merchandise prices: <strong>#NumberFormat(MerchStdD

Página 32

38 CHAPTER 30 Extending ColdFusion with CFXGenerating Debug OutputIf your CFX tag encounters any problems during its execution, or if you need help fig

Página 33

39Returning Structures from CFX TagsReturning Structures from CFX TagsAs you probably already know, ColdFusion supports a feature referred to in the d

Página 34 - Compiling Your New CFX Tag

4 CHAPTER 30 Extending ColdFusion with CFXTable 30.3 C++ Methods for Working with AttributesMETHOD DESCRIPTIONpRequest->AttributeExists(lpszName) D

Página 35 - Using the New Tag

40 CHAPTER 30 Extending ColdFusion with CFXAside from the name of the tag, the code is exactly the same as Listing 30.6 except that these lines:// Con

Página 36 - <!

41Returning Structures from CFX TagsListing 30.8 (continued)<!---Retrieve merchandise information from database---> <cfquery datasource=”ows

Página 37 - Other C++ Examples

42 CHAPTER 30 Extending ColdFusion with CFXListing 30.8 (continued)<br>Standard Deviation:<strong>#NumberFormat(MerchStats.StandardDeviati

Página 38 - Generating Debug Output

43Using CFX Tags Safely: Locking and Thread SafetyEither line of code, used immediately before the CFX tag, will guard against any potential problemsi

Página 39 - CFX Tags Are Smart, Too

44 CHAPTER 30 Extending ColdFusion with CFXIf the CFX Tag Works with FilesIf the guts of the CFX tag are thread-safe, but you are asking the tag to do

Página 40 - ) is included as well

5Introducing the CFX APIWorking with QueriesAny CFX tag may return queries to the ColdFusion page that is calling the tag. The queries canthen be used

Página 41

6 CHAPTER 30 Extending ColdFusion with CFXTable 30.7 C++ Methods for Working with QueriesMETHOD DESCRIPTIONpRequest->AddQuery(name, columns) Create

Página 42 - Figure 30.12

7Introducing the CFX APITable 30.8 C++ Methods for Working with String SetsMETHOD DESCRIPTIONstringset->AddString(string) Adds a LPCSTR value to th

Página 43 - Understanding Thread Safety

8 CHAPTER 30 Extending ColdFusion with CFXTable 30.9 (continued)METHOD DESCRIPTIONrequest.debug() Determines whether the tag has beencalled with the d

Página 44

9Writing CFX Tags with Java2. Compiling the Java code into the corresponding .class file3. Registering the new CFX tag in the ColdFusion AdministratorI

Comentários a estes Manuais

Sem comentários