Nov
25
ColdFusion
· By Michael Ferguson
If you think the built-in drop shadow for the CFWINDOW render is too weak, there is a way you can provide the illusion that the window is further away from the main content. To make the change for every CFWINDOW on the server you can edit the theme CSS in the CFIDE (ColdFusion 8) or the "ext-all.css" file (ColdFusion 9) also in the CFIDE folder, or to just change one page add the following style statement.
<style type="text/css">
.x-ie-shadow {
background: #000;
zoom: 1.01;}
</style>
Just like the CFGRID border style statement from the previous entry, this works because styles are the executed in the order presented. Last one loaded, wins.
If you find this post useful please leave a comment and let me know how you used the information.
Nov
25
ColdFusion
· By Michael Ferguson
I noticed that ColdFusion 9 has a two pixel border around the CFGRID render thanks to the ext-all cascading stylesheet. In case you want to know how to remove the border, you can either edit the "ext-all.css" file in your CFIDE folder (which will remove the border from every CFGRID) or just add the following style statement in your CFGRID page (which will only change the current page).
<style type="text/css">
.x-grid-panel .x-panel-body {
border: 0px;}
</style>
This works because styles are the executed in the order presented. Last one loaded, wins.
If you find this post useful please leave a comment and let me know how you used the information.
Oct
24
ColdFusion
· By Michael Ferguson
I was recently working with a need to compare two results from a single User Defined Function (UDF). On the surface, this is impossible since a function can only return one result. However, that limitation can be overcome if that result is a structure of all the results given in a set of calculations.
In the example below, I've really simplified a function into something that you wouldn't necessarily bother to return as a structure, but this is just to help get a down and dirty idea across without getting bogged down in a complex UDF.
Here we are trying to determine what the last day of the current month is and how many days until that date.
<cffunction name="fnMonthLastDay" access="public" returntype="struct">
<cfargument name="SetDate" type="string" required="yes">
<cfscript>
var SetYear=DatePart("yyyy", SetDate);
var SetMonth=DatePart("m", SetDate);
if (ArrayLen(Arguments) GT 1)
SetYear=Arguments[2];
LastDay=StructNew();
LastDay.LastDate=DateAdd("d", -1, DateAdd("M", 1, CreateDate(SetYear, SetMonth, 1)));
LastDay.LastDays=DateDiff("d", Now(), LastDay.LastDate);
return LastDay;
</cfscript>
</cffunction>
<cfset LastDay=fnMonthLastDay(Now())>
<cfdump var="#LastDay#">
The UDF grabs the year and month from the date value passed, advances it to the first of the following month, then subtracts one day from it to determine the last day. Then the UDF calculates the difference between the two dates and returns a structure. We set the result against a variable, in case we want to use it more than once and end by dumping the structure LastDay with two elements (LastDate, and LastDays).
If you find this post useful please leave a comment and let me know how you used the information.
Oct
17
ColdFusion
· By Michael Ferguson
In sharp contrast to how make SQL deal with a list value, ColdFusion is very versatile. Although the SQL version of this example can be very confusing to look at, the ColdFusion version is very short and easy to understand. What programmers forget to do sometimes, is give more data manipulation to the SQL server. Most of the time the server is just sitting there waiting for the formatted data to be sent to it from ColdFusion, or waiting for a query request. We tend to give everything to ColdFusion to do, causing our processes to slow down while our SQL server is barely used.
Here is how list values can be extracted in ColdFusion:
<cfset NameConcat="John.Q.Public">
<cfset NameFirst=ListGetAt(NameConcat, 1, ".")>
<cfset NameLast=ListGetAt(NameConcat, 3, ".")>
<cfset NameMI=ListGetAt(NameConcat, 2, ".")>
Very short, very easy to understand, ListGetAt just returns the substring from the position in the list as defined.
If you find this post useful please leave a comment and let me know how you used the information.
Oct
3
ColdFusion
· By Michael Ferguson
Ever tried to rename a directory to the same name but with different letter case through CFDIRECTORY? Does not work to well on a Microsoft Windows platform. Why? Unlike Linux, Windows sees the names "MyDirectory", "MYDIRECTORY", and "mydirectory" as the same. Here is a Java call through CFSCRIPT that will allow you to rename a folder between the different cases.
<cfscript>
src=CreateObject("java", "java.io.File").init("c:\mydirectory");
dest=CreateObject("java","java.io.File").init("c:\MyDirectory");
src.RenameTo(dest);
</cfscript>
Remember, this works because Java is platform independent. For this reason, unlike CFDIRECTORY on a Windows machine, it won't see the three directory names in the paragraph above as the same item.
Obviously, you wouldn't want to hard code a directory rename. After all, it would run once, rename the directory and never run again. For this reason, for usability just substitute the two absolute folder names with variables that are selected through the process of your choice and design.
If you find this post useful please leave a comment and let me know how you used the information.