September 20, 2011
Read File line by line in ColdFusion by using Java Classes

I was having situation where I wanted to read a file and process each line.
I think cffile tag is not much to do it, so I use java classes.
Basically we need two kinds of classes.
1. InputSream
2. Buffer reader

Buffer reader is capable to read any input stream line by line.

Final code will look like:

	FileName = expandPath('/temp.txt');
	objFileReader = createObject("java","");
	InputStreamReader = objFileReader.init(FileName);
	objBuffer = createObject("java","" );
	LineIO = objBuffer.init(InputStreamReader);
	<cfset eof = 0>
	<cfset cnt = 1>
	<cfloop condition="not eof">
	<cfset currline = LineIO.readline()>
	<cfif isdefined("currline") eq "no">
	<cfset eof = 1>
	<cfoutput>line #cnt#: #currline#<br/></cfoutput>
	<cfset cnt = cnt + 1>

By Vikas
Tags: File, ColdFusion
September 20, 2011
Complex password strength checking through regular expression

Currently working on project for well non credit card company where they have online registration form. They really want user enter enter strong password for their account and criteria for password listed below..

  1. Password must length between 8 to 18.
  2. Password must contain atleast one alpha and on numeric.
  3. Password must have one special characters from @,#,$.
  4. Password can not have repeative alpha and numeric.

This is really complex but can be done with four different conditions easily (right?) but I decided to make things more complex and check all four condition with single regular expression. After spending time on this finally figure out regular expression can perform all four condition.

Tags: Regular Expression, ColdFusion
September 6, 2011
Making Paypal standard checkbout more user friendly

Recently working with paypal standard checkout and it so easy to integrate with any application as it will redirect to paypal site and customer login and make all kind of payment stuff at paypal site only. But this task make really tuff for new customer who has limited knowledge of intenernet/paypal.

How this works? Well, paypal has very good documentation here. Basic flow is.

  1. Customer click on "Paypal" button which redirect to paypal site.
  2. Customer need to login or enter credit card information.
  3. Paypal ask for confirmation of payment.
  4. Thanks page for placing order with link to return original site.
Tags: Paypal
September 4, 2011
Static method implementation in ColdFusion

I found some discussion about static method equivalence in ColdFusion.

In C# we can declare class as static and static class can only have all the static methods and static variables. And we can call static class methods without creating its instance.

In ColdFusion we must need to create an instance of cfc. Then & then we can call it’s method. To avoid creating instance each time, you can create object in Application init() function, and make it at application scope, so you can directly call the methods. But this is still a nasty approach, as we are still creating an object when Application initializes.

Then I remember that ColdFusion is not an Object Oriented Language. We make it look like OOP! It happens mostly when we use ColdBox or Model Glue or any other application framework, where most of the coding is in cfc only. Now a days people are using cfscript tag more as Lots of tags are now available in cfscript. And when we use cfscript tag we, feel like it's an OOP language! But remember ColdFusion is a scripting language as PHP and Classic asp. cfscript tag itself trying to remind us by its name!


By Vikas
Tags: ColdFusion
August 27, 2011
sql server(store procedure) mechanism convert empty string date parameter to initial date(1900-01-01)

Hello Friends, It may you know about it but I would like to share this thing with you. We were working on one of project where we faced issue. we are storing data through sql server store procedure using date parameter. As per our logic, the date parameter has not date value it may be empty string. Whenever date parameter has empty string sql server store initial date(1900-01-01) in the date field. We checked our whole logic to find out how the initial date come if date parameter has an ...

By Bharat Patel
Tags: SqlServer
August 19, 2011
Work around ColdFusion local scope

Hi friends,

These days am working as a tester. I never thought that developer can also do that if they really take interest in testing! Infect someone can also learn from the testing, even testing can also test their understanding for knowledge.

While testing I saw one case where I get more variable in the array object other then I defined. Then I again take a look and I came to know that local variable was causing an issue.

Let me give you some examples and exercise. Make sure that before you see the output just think what would be the output. Consider that all following code is written in sample cfml page and we are using ColdFusion 9.

By Vikas
Tags: ColdFusion9, ColdFusion
August 17, 2011
Bug - count() function in ColdFusion query of query


It has been a great time since I started working on ColdFusion. I must say that it is the easiest language in the world and yet it is a powerful and can be compared to any major programming language.

In last few days, I was using ColdBox and MockBox framework in our current project. I was using query of query which is very similar to SQL query, and we can use it over query object in ColdFusion.

Count() is a math function, but if we use it with select statement like count(*), it returns a number of rows fetched in select query. I used it query of query, and it was giving me the correct count if my select statement is returning some rows, but if it is not returning any row then ideally it should give 0 as output, but it gives [empty string].

By Vikas
Tags: ColdFusion9, ColdFusion
August 8, 2011
How to use SQLite manager extension in Firefox?

Hi friends,

It was really strange when I installed an extension from Mozilla and I cannot find how to use it!!

Well Then I think there must be an icon, which I don't see on tool bar.

Right click on the top of the Firefox, and choose customize.
Then look for the SQLite icon, drag it to toolbar. Click on the icon to use it.

Simple? I can't say, because I find bit difficult!

Tags: FireFox
August 8, 2011
Understanding event handler and parallel processing


These days I am trying to play with browser’s local database. I get very much interesting experience while assigning a value to variable.

I used the following code in JavaScript (Only works in Firefox) ...

By Vikas
Tags: JavaScript
August 6, 2011
How to use query of query in cfscript

We can use queries of queries in cfscript with the Query.cfc. But this is possible in Coldfusion 9 because Query.cfc has introduced in Coldfusion 9.

Let's see the following code ...

Tags: ColdFusion9, ColdFusion