Sunday, August 1, 2010

ColdFusion SpreadSheet enhancement in 9.0.1

ColdFusion 9.0.1 also adds few enhancements for interacting with spreadsheets. There is significant performance improvement over formatting large number of rows and columns. Also added was a neat function to format a group of cells.

SpreadsheetFormatCellRange

Example: 

SpreadSheetFormatCellRange(spreadSheetVar,{bold='true',color='red',fontsize='15'},2,2,10,20);

This will format rows 2 to 10 and columns 2 to 20.

ColdFusion Updater 9.0.1 and Solr

There are lot enhancements done in ColdFusion wrt Solr in 9.0.1. There are few issues but: If you are running into this exception ""java.lang.NoClassDefFoundError: org/ccil/cowan/tagsoup/Parser" while indexing documents, you will need the following jar in ColdFusion lib directory:

http://dl.dropbox.com/u/7302119/tagsoup-1.2.jar
This happens when some binary files like .nfo are indexed and ColdFusion is unable to parse the file.

Get CF 9.0.1 here: http://www.adobe.com/go/getcf901

Sunday, August 23, 2009

Dynamic Power Point presentation using ColdFusion

The below code snippets will show you how you can generate a dynamic power point using ColdFusion 9.
This is the start of the code:

<cfpresentation format="ppt" destination="f:\test\a.ppt" title="" overwrite="yes">
The code for the first slide:

<cfpresentationslide>
<html>
<body background="file:///f:/temp/bg1.jpg">
<h1 style="color:YELLOW"> This is pure HTML page </h1>
<h2 style="color:RED"> Sub title </h2>
<ul>
<li> test 1 </li>
<li> test 2 </li>
<li> test 3 </li>
</ul>
</body>
</html>
</cfpresentationslide>
The code for the second slide. This is a dynamic slide having a chart generated from a database:

<cfpresentationslide>
<cfquery name="GetSalaries" datasource="cfdocexamples">
SELECT Departmt.Dept_Name,
Employee.Dept_ID,
Employee.Salary
FROM Departmt, Employee
WHERE Departmt.Dept_ID = Employee.Dept_ID
</cfquery>

<cfquery dbtype = "query" name = "DataTable">
SELECT
Dept_Name,
AVG(Salary) AS avgSal,
SUM(Salary) AS sumSal
FROM GetSalaries
GROUP BY Dept_Name
</cfquery>

<!--- Reformat the generated numbers to show only thousands. --->
<cfloop index = "i" from = "1" to = "##DataTable.RecordCount##">
<cfset DataTable.sumSal[i] = Round(DataTable.sumSal[i]/1000)*1000>
<cfset DataTable.avgSal[i] = Round(DataTable.avgSal[i]/1000)*1000>
</cfloop>

<!--- Bar graph, from Query of Queries --->
<cfchart format="jpg"
xaxistitle="Department"
yaxistitle="Salary Average">

<cfchartseries type="bar"
query="DataTable"
itemcolumn="Dept_Name"
valuecolumn="avgSal">

<cfchartdata item="Facilities" value="35000">

</cfchartseries>
</cfchart>
</cfpresentationslide>
The code for the third slide. This shows an example of text formatting using HTML:

<cfpresentationslide >
<html>
<body style="color:GREEN" >

<h4 style="color:BLUE"> Some examples of HTML text formatting</h4>
<p><b>This text is bold</b></p>
<p><strong>This text is strong</strong></p>
<p><big>This text is big</big></p>
<p><em>This text is emphasized</em></p>
<p><i>This text is italic</i></p>
<p><small>This text is small</small></p>
<p>This is<sub> subscript</sub> and <sup>superscript</sup></p>
</body>
</html>
</cfpresentationslide>
Close the slides:

</cfpresentation>
The generated first slide:
The generated second slide:

The generated third slide:

Friday, August 21, 2009

Tuning ColdFusion Solr: Part 2

Don't forget to tune Solr Server for increased performance. First thing to do is to increase the Xmx value for Solr Server. To do so:

1) In windows -
* Shutdown Solr service
* Open solr.lax under Solr installation directory and modify the default setting -Xmx256m to -Xmx1024m.
* Start service
2) In Unix -
* Stop solr by going to solr installation directory and say:
./cfsolr stop
* Open cfsolr script and modify modify the default setting -Xmx256m to -Xmx1024m.
* Start by running the command:
./cfsolr start.

Tuning ColdFusion Solr: Part 1

In ColdFusion administrator, under "Solr Server", click on "Show Advanced Settings" and you will see a text box labled "Solr Buffer Limit". This is set to 40. This means when indexing documents, documents will be committed after every 40 KB of data. If you have allocated enough memory for ColdFusion say 1024m, increase this value to 80 and you can see increase in performance when indexing huge amount of data (especially text files).

Thursday, August 20, 2009

Searching for synonyms..

Solr supports searching synonym words. This means that if you have word called "computer" in your index, you can search using its synonyms like CPU, PC etc. To achieve this you will need to do the following :
(This example is for configuring Solr distributed through ColdFusion)

Under your collections directory (Lets say C:\ColdFusion\Collections\solrcollection), there will be a conf directory, under which you will have a synonyms.txt. Shutdown Solr and open the file.

Add your synonyms list in that.
Ex:
computer,PC,CPU,calculator
Save, exit and restart Solr service or process.

There are many synonym list available online. One such can be found here:

http://www.gutenberg.org/etext/3202

Loading the complete list is not a good idea because you will run out of memory. Add only what is relevant and have a small list. Try to convert to small cases wherever applicable and remove spaces.

To have the synonyms applicable to all collections, do the following:
Goto the Solr installation directory and browse to multicore\template\conf direcory.
Ex: C:\ColdFusion9\solr\multicore\template\conf

Update the synonyms.txt. This should be done before creating a collection.
The synonyms are mostly specific to your application. Say you are indexing books, you might want to have synonyms like rowling,potter,hogwarts etc (something similar to the labels).

Monday, August 17, 2009

Installing ColdFusion 9

If you want to install ColdFusion silently, follow these steps:

coldfusioninstaller.exe -i silent -f <property file>

The silent property file example is as below:

INSTALLER_UI=SILENT
SILENT_LICENSE_MODE=full
SILENT_SERIAL_NUMBER=
SILENT_INSTALLER_TYPE=standalone
SILENT_INSTALL_ODBC=true/false
SILENT_INSTALL_VERITY=true/false
SILENT_INSTALL_SAMPLES=true/false
SILENT_INSTALL_JNBRIDGE=true/false
SILENT_INSTALL_FOLDER=F:\\ColdFusion9
SILENT_WEBROOT_FOLDER=F:\\ColdFusion9\\wwwroot
SILENT_ADMIN_PASSWORD=password
SILENT_FLEX_ENABLED=true
SILENT_ENABLE_RDS=false
Note the two "\" as path separator. Without "\\" it will not uninstall.
Once installation is complete, Adobe_ColdFusion_9_InstallLog.log will be available under the directory you specified.
You can control the temp directory by setting temp to another directory:
set tmp=f:\temp
Incase of unix,
export IATMPDIR=somedirectory