This post highlights the difference between the ColdFusion Administrator Mappings section and the virtual directories.
The ColdFusion 8 and 9 Admin documentation pretty much explains everything (see highlighted note):

ColdFusion mappings let the cfinclude and cfmodule tags access pages that are outside the Web root. If you specify a path that starts with the mapping’s logical path in these tags, ColdFusion looks for the page using the mapping’s directory path.
ColdFusion also uses mappings to find ColdFusion components (CFCs). The cfinvoke and cfobject tags and CreateObject function look for CFCs in the mapped directories.
Note: These mappings are independent of web server virtual directories. If you would like to create a virtual directory to access a given directory through a URL, please consult your web server documentation.

So, the mappings defined in the CF Admin (CFAdmin > Server Settings > Mappings) are defined so that ColdFusion is able to access pages outside of your web root. That’s because ColdFusion will not ‘see’ the virtual directories defined in your web server configuration.
Either if you use the JRun server, Apache or other flavors, the ColdFusion will not know anything about their configuration.

Let’s take an actual example: (more…)

Try the following example in your browser.

simple_jstest.cfm


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test js length</title>
<style>
#foo {width: 420px; height:70px; font-size:12px;}
#sbmt_btn {font-size:12px;}
</style>
</head>

<body>

<cfset str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Pellentesque bibendum tristique dignissim.">

<cfoutput>
String Length=#len(str)# characters

<form action="##" name="form1" id="form1" method="post" onsubmit="myfunc()">
	<textarea name="foo" id="foo" cols="30" rows="3">#str#</textarea> <br />
	<button type="submit" name="sbmt_btn" id="sbmt_btn">Submit</button>
</form>
</cfoutput>
		
<script type="text/javascript">
function myfunc()
{
	var myval = document.getElementById('foo').value;
	alert(myval.length);
}
</script>

</body>
</html>

(more…)

ColdFusion: cfdbinfo usage

Written on 17 March 2011, 11:40pm

Tagged with: , , ,

The cfdbinfo tag, introduced back in ColdFusion 8 provides a lot of information about your database environment. The documentation page shows 7 distinct values for the ‘type’ attribute of cfdbinfo:

type=”dbnames|tables|columns|version|procedures|foreignkeys|index”
Type of information to get:
* dbnames: database name and type
* tables: name, type, and remarks
* columns: name, SQL data type, size, decimal precision, default value, maximum length in bytes of a character or integer data type column, whether nulls are allowed, ordinal position, remarks, whether the column is a primary key, whether the column is a foreign key, the table that the foreign key refers to, the key name the foreign key refers to
* version: database product name and version, driver name and version, JDBC major and minor version
* procedures: name, type, and remarks
* foreignkeys: foreign key name and table, primary key name, delete, and update rules
* index: name, column on which the index is applied, ordinal position, cardinality, whether the row represents a table statistic or an index, number of pages used by the table or index, whether the index values are unique

This post shows some simple examples for the 7 cases described above to give you a better grip on this tag.

1. Get the databases

<cfset dsn = "YOURDSN">

<cfdbinfo
    type="dbnames"
    datasource="#dsn#"
    name="dbdata">

<cfoutput>
The #dsn# data source has the following databases:<br />
</cfoutput>
<cfdump var="#dbdata#">

It’s important to note that the cfdbinfo returns in this case all the databases, not just the one defined in the data source.

2. Get the tables of a database

<cfdbinfo
    type="tables"
    datasource="#dsn#"
    name="dbdata">

<cfoutput>
The #dsn# data source has the following tables:<br />
</cfoutput>
<cfdump var="#dbdata#">

In MySQL – the cfdbinfo above returns only the tables of the database defined in the data source.
In Oracle – the cfdbinfo above returns all the tables in all the databases returned at point 1.
To filter the returned tables, you can use the following two attributes: (more…)