Framework with more features and real usage

February 12, 2007

Months ago when I heard of the term framework which generate Add/Mod/Del functionality, I was quite surprise and realize that how helpful it could be. It will save a lot of hours I spend on the most part, increase efficiency and will be bug free :). After trying with some framework, I found it does the right job but not with style I write the code. Its interanal are too difficult to understand and modifying such code eats up more time than I ever expected. I thought Its better idea to go the way I/we code. Later after thinking for some time on the right concept, its clear many thing and I realizes building framework is not a tough job. In my earlier post I already talked about when I started with it. This time I develop more better version of code.

I used pear DB class for database and Smarty for templating as most of the PHP developers are using it.

What features my frameworks offer this time?

-Generate Class file based on the table Structure.
-Generate Templates for AddUpdate as well as for Listing the records.
-Sorting on the each column field.
-Pagination.
-Server Validation for Unique values.
-Javascript validation for Blank Values currently.
-Generate JS map which we can use for further validation.
-Complete Add/Modify/Delete.
-Debug options which allow development message enable disable.
-Generate Links based on the class available.
-Search on the table field

New Features I will be adding this month
-Basic Ajax Functionality

Framework is flexible enough to add new functinality in code. Even this framework has ability to generate Coldfusion, ASP as well as Java code.

I soon will be submitting it to sourceforge.net and host it for the developers to take a look about what I am talking.

🙂


Coldfusion use cfexecute to execute server side executable

December 13, 2006

For Quite some time I was thinking of how we can execute any executables on the server. While browsing the net for coldfusion articles I am across cfexecute tag. So finally I got the tag which satisfy my needs.

We have some third party executables which converts our files into different format. But how to use this utility via web using coldfusion was question mark for us. Originally the idea was there in my mind about such kind of tag. Which I thought coldfusion must be offering, thats true it offered such tag. Coldfusion is Great!

We will like this.

-We will upload file on the server on to the specified url
-will use cfexecute command with script once the file is uploaded and will pass necessary arguments.

Cfexecute tag looks like

<cfexecute
name = ” Application Name ”
arguments = “arguments”
outputFile = “Output file name”
timeout = “Timeout interval”>

</cfexecute>

name :
attributes require the application absolute path which we want to execute at the server side.

arguments :
arguments required by the application eg filename and output file format

outputFile :
This dump the response messages into specified file. eg. File is successfully converted.

timeout:
This is the timelimit till the coldfusion server waits for the response from application.

You can find more information about the cfexecute at the livedocs.


Easy file uploading with Coldfusion

December 2, 2006

File uploading seems to be very basic feature that of every web application. Coldfusion offers very easy way for uploading file on the server. Single tag “cffile” for multiple needs.

<cffile action=”upload” destination=”c:\temp\” nameConflict=”overwrite” fileField=”Form.FiletoUpload”>

action
-Specify different values for it in this case upload

destination
-Where your file will get saved.

nameConflict
-This attributes tell the coldfusion when file is available on server. Should it be overwrite, skip, or need to create with new name

fileField
-Name of the files that has to be uploaded.

Also in html form part, you need to define form enctype=”multipart/form-data”. This tell coldfusion that file has been submitted by web browser.

-Create html form for file uploading
-Create cfm page  for your coldfusion scripting
-Check wheater form has been submitted or not
-Submitted then run the cffile tag


Application.cfm AND Application.cfc not working in similar manner.

November 28, 2006

I am working on the ColdfusionMX7 and Application.cfm is not working properly, I defined application variable and tried to output it on cfm page its giving me error

Element PAGENAME is undefined in APPLICATION.

My Application.cfm look like

<cfapplication name=”TestApp1″ clientManagement=”yes” sessionmanagement=”yes”>
<cfset Application.pageName=”foo”>
</cfapplication>

Where as Application.cfc is working well, its look like

<cfcomponent displayname=””>
<cfset this.name=”testApp1″>
<cffunction name=”onapplicationStart” returntype=”boolean” output=”false”>
<cfset Application.pageName=”Application Inside page”>
<cfreturn true>
</cffunction>
</cfcomponent>

What difference in between them? Any ideas


Coldfusion trick we did to find values in array

November 24, 2006

In coldfusion I didnt find function to find values within array. Requirement was to look wheather specific value is present or not. Such function is present in PHP.

I look for various implmentation and I though structure could solve this issues. And magic logic works. Let me explain you what we did

-We received array, we converted it to the structure.
-Each value from the array is now treated as key in structure
-At the end we used structKeyExists function.

This way we achieved the functionality that we need.


Coldfusion redirect to different url

November 24, 2006

While developing application, many times I found the need of redirecting your current page. Coldfusion has a nice cflocation tag which allow you load/redirect new page in the browser.

In between your script, when cflocation tag arrives, coldfusion simply stops the execution of the current page and opens a new page provided as url to cflocation tag.


Ternary Operator implemenation in PHP and Coldfusion

November 22, 2006

What is Ternary Operator ?

t’s a shortcut for an if-else statement, and is also known as a conditional operator. Its operate on the three input

Ternary operators save time and lines of code. Its more preferable when you are performing simple conditional operation.

In PHP it works as:

“boolean_condition?true_value:false_value”

In coldfusion it works as:

There is not any direct implementation of operator, but coldfusion uses function IIf for the same purpose

Syntax : IIf(condition, string_expression1, string_expression2)

Without Ternary Operator

var a=1,c=””;
if(a==1)
{
c=”Hello”;
}
else
{
c=”Bye”;
}

With Ternary Operator

var a=1,c=””;
c=(a==1)?”Hello”:”Bye”;