Wednesday, March 18, 2009

ColdFusion Java CFX Reference

ColdFusion Java CFX Reference

Tacking from http://docs.fusionlink.com/coldfusion

ColdFusion includes Java interfaces for building ColdFusion custom CFXs in Java.

Contents

Class libraries overview

The following Java interfaces are available for building ColdFusion custom CFXs in Java:

:

Interface

Methods

Custom tag interface

processRequest

Query interface

addRow

getColumnIndex

getColumns

getData

getName

getRowCount

setData

Request interface

attributeExists

debug

getAttribute

getAttributeList

getIntAttribute

getQuery

getSetting

Response interface

addQuery

setVariable

write

writeDebug

Custom tag interface

public abstract interface CustomTag
Interface for implementing custom tags. 

Classes that implement this interface can be specified in the CLASS attribute of the Java CFX tag. For example, in a class MyCustomTag, which implements this interface, the following CFML code calls the MyCustomTag.processRequest method:

Query interface

public abstract interface Query
 

Interface to a query used or created by a custom tag. A query contains tabular data organized by named columns and rows.

Methods

Returns

Method

Description

int

addRow()

Adds a row to the query

int

getColumnIndex(String name)

Gets the index of a column given its name

String[]

getColumns()

Gets a list of the column names in a query

String

getData(int iRow, int iCol)

Gets a data element from a row and column of a query

String

getName()

Gets the name of a query

int

getRowCount()

Gets the number of rows in a query

void

setData(int iRow, int iCol, String data)

Sets a data element in a row and column of a query

Request interface

public abstract interface Request

Interface to a request made to a CustomTag. The interface includes methods for retrieving attributes passed to the tag (including queries) and reading global tag settings.

Response interface

public abstract interface Response

Interface to response generated from a custom tag. This interface includes methods for writing output, generating queries, and setting variables in the calling page.

Methods

Returns

Syntax

Description

Query

addQuery(String name, String[] columns)

Adds a query to the calling template.

void

setVariable(String name, String value)

Sets a variable in the calling template.

void

write(String output)

Outputs text back to the user.

void

writeDebug(String output)

Writes text output into the debug stream.

Debugging classes reference

The constructors and methods supported by the DebugRequest, DebugResponse, and DebugQuery classes are as follows. These classes also support the other methods of the Request, Response, and Query interfaces, respectively.

DebugRequest

// initialize a debug request with attributes
public DebugRequest( Hashtable attributes ) ;
 
// initialize a debug request with attributes and a query
public DebugRequest( Hashtable attributes, Query query ) ;
 
// initialize a debug request with attributes, a query, and settings
public DebugRequest( Hashtable attributes, Query query, Hashtable settings ) ;
 

Replace with coldfusion

Replace

Description (http://livedocs.adobe.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=00000611.htm)

Replaces occurrences of substring1 in a string with substring2, in a specified scope. The search is case-sensitive.

Returns

The string, after making replacements.

Parameters

Parameter

Description

string

A string or a variable that contains one. String in which to search.

substring1

A string or a variable that contains one. String for which to search

substring2

String that replaces substring1

scope

  • one: replaces the first occurrence (default)
  • all: replaces all occurrences

Usage

To remove a string, specify the empty string ("") as substring2.

You do not need to escape comma characters in strings. For example, the following code deletes the commas from the sentence:

replace("The quick brown fox jumped over the lazy cow, dog, and cat.",",","","All")

Wednesday, March 4, 2009

Using Ajax with coldfusion

http://livedocs.adobe.com/coldfusion/8/htmldocs/index.html

cfajaxproxy
Description
Creates a JavaScript proxy for a ColdFusion component, for use in an AJAX client. Alternatively, creates a proxy for a single CFC method, JavaScript function, or URL that is bound to one or more control attribute values.
Category
Internet protocol tags
Usage
Make sure that the Enable HTTP Status Codes option on the Server Settings > Settings page of the ColdFusion Administrator is selected. Otherwise, the proxy cannot determine if an error occurs in invoking the CFC function and cannot call the error handler.
A cfajaxproxy tag with a bind attribute does not refresh any control that is not specified in the bind expression.
If you specify a URL in the bind attribute, the HTTP response must consist of a single JSON representation of an object, array, or simple value, corresponding to the onSuccess argument.
Creating a CFC proxy
The cfajaxproxy tag with a cfc attribute generates a JavaScript proxy that represents a CFC on the web client. The tag and the proxy it generates have the following characteristics:
§ The proxy provides one function that corresponds to each CFC remote function. Calling these functions in your client-side JavaScript code remotely calls the CFC functions on the server.
§ The proxy provides several functions that you call to configure the interaction between the client and the server. These functions set the HTTP method and synchronization mode of the XMLHttpRequest call that the proxy uses to interact with the server. The functions also can specify a JavaScript callback handler and an error handler for asynchronous calls.
§ Because JavaScript is case-sensitive, you must ensure that you match the case of the keys in any ColdFusion structure or scope that you send to the client. By default, ColdFusion sets variable names and structure element names to all-uppercase. (You can create structure element names with lowercase characters by specifying the names in associative array notation, for example, myStruct["myElement"]="value".) The keys for the two arrays in the JSON object that the ColdFusion serializeJSON tag generates to represent a query are COLUMNS and DATA, for example, not columns and data.
For detailed information on using AJAX CFC proxies, see "Using ColdFusion Ajax CFC proxies" in "Using Ajax Data and Development Features" in the ColdFusion Developer's Guide.
Note: The proxy passes a _CF_NODEBUG Boolean argument to called CFC functions. ColdFusion checks this value, and when it is true, does not append to the response any debugging information that it normally would send. This behavior ensures that the JSON responses to AJAX requests do include any non-JSON (i.e., debug information) text