
February 10 2009 by

admin
Back in the olden days of CFML there was a script called CF_Select_Two_related. It allowed you to select from one dropdown <select > and populate the second dropdown <select > with related data from a query. 10 years ago it was really cool.
But now in ColdFusion 8 you can use the bind attribute and bind to a cfc passing data to it from other cfselects. Its AJAX so no page refresh and its very cool and useful. However, there is one pit fall you must know.
If you have so much as ONE comment in application dot cfm or cfc, the bind onload function will fail and the your cool dropdowns will just sit there.
Hopefully there is a plan to fix that in CF 10.
Here is an example from: http://blog.web-shorts.com/post/cfselect-binding-and-selectedvalues
<cfselect
name="city_id"
bind="cfc:cfcs.Remote.getCities({inventoryDetails:state_id}, #MyProperty.getCity_ID()#)"
bindOnLoad="true"
value="ID"
display="CityName"
/>
Remote.cfc
<cffunction name="getCities" access="remote" returntype="query" hint="Returns a query of cities for a specific state">
<cfargument name="state_id" type="numeric" required="true" />
<cfargument name="selectedValue" type="numeric" required="false" default="0" />
<cfset var rs = "" />
<cfif Val(Arguments.State_ID) IS 0>
<cfset rs = QueryNew("ID, CityName") />
<cfset QueryAddRow(rs) />
<cfset QuerySetCell(rs, "ID", 0) />
<cfset QuerySetCell(rs, "CityName", "Choose a state first...") />
<cfelse>
<cfquery name="rs" datasource="#DSN#">
SELECT
ID
, CityName
FROM (
SELECT
ID
, CityName
, CASE WHEN ID = <cfqueryparam cfsqltype="cf_sql_integer" value="#Arguments.SelectedValue#" />
THEN 0
ELSE 1
END AS Sort
FROM City (NOLOCK)
WHERE State_ID = <cfqueryparam cfsqltype="cf_sql_integer" value="#Arguments.State_ID#" />
) d
ORDER BY Sort, CityName
</cfquery>
</cfif>
<cfreturn rs />
</cffunction>
Posted in CFC Binding |
3 comments

February 06 2009 by

admin
Lately I've been coding a lot of traditional HTML tables with SPRY. I transform cfquery data into XML using Spry.Data.XMLDataSet. For whatever reason I find it easier than using a JSON object. Over the last couple of weeks I periodically come across one of the following error messages:
| Diagnostics: |
An error occured while Parsing an XML document. The reference to entity "foobar" must end with the ';' delimiter. The error occurred on line 69. |
or
| Diagnostics: |
An error occured while Parsing an XML document. The The entity name must immediately follow the '&' in the entity reference. The error occurred on line 69. |
Ahhhhhrrrrrrrrggggggggg!!!!!!!
So for the past week (one day I spent 5 hours on it) I've been looking over where the error is in the data and I've come to this conclusion. When an apersand exists in a datacolumn which is immediately followed by any letter the first error occurs. And when the apersand is bounded by spaces the second error occurs. At least this is what my data showed.
So how to fix it. I work for a commercial vehicle leasing company so the XML will reflect that type of data.
Fix 1 (this fix removes the Ampersand reference and replaces it with ' and ':
<yrmakemodel>#replace('2004 Ford F-250 w/plow&spreader', '&',' and ','ALL')#</yrmakemodel>
Fix 2 (this fix keeps the Ampersand reference) but It may cause some performance issues depending on the depth of the data. At least thats out experience.
<yrmakemodel><![CDATA[2004 Ford F-250 w/plow&spreader]]></yrmakemodel>
Posted in Spry |
4 comments

February 03 2009 by

admin
Coldfusion raises an illegal exception: you see an error message about a corrupt table when the "Maximum number of cached queries" size is less than the number of queries to be cached by an application.
Install the ColdFusion 8 hot fix.
Download the hot fix (http://www.adobe.com/support/coldfusion/ts/documents/kb402583/hf800-70332.zip).
Extract hf800-70332.jar from the hf800-70332.zip file.
Open the ColdFusion Administrator and select the System Information page. Next to the Update File field, either:
Type in the file path to hf800-70332.jar and click Submit.
OR
Select the Browse Button and browse to the hf800-70332.jar. Select the file and click Submit.
Restart the ColdFusion Server.
Note: The ColdFusion 8 hot fix JAR file does not need to be retained after installing it with the ColdFusion Administrator. The file has been copied into the correct location.
Posted in ColdFusion Hotfixes |
5 comments

December 16 2008 by

admin
Down and dirty. Pass it around.
GO
/****** Object: Table [dbo].[US_States] Script Date: 10/07/2008 15:32:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[US_States](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](50) NOT NULL,
[Abbreviation] [nchar](2) NOT NULL
) ON [PRIMARY]
insert into US_States values ('Alabama' , 'AL')
insert into US_States values ('Alaska' , 'AK')
insert into US_States values ('Arizona' , 'AZ')
insert into US_States values ('Arkansas' , 'AR')
insert into US_States values ('California' , 'CA')
insert into US_States values ('Colorado' , 'CO')
insert into US_States values ('Connecticut' , 'CT')
insert into US_States values ( 'Delaware' , 'DE')
insert into US_States values ( 'District of Columbia' , 'DC')
insert into US_States values ( 'Florida' , 'FL')
insert into US_States values ( 'Georgia' , 'GA')
insert into US_States values ( 'Hawaii' , 'HI')
insert into US_States values ( 'Idaho' , 'ID')
insert into US_States values ( 'Illinois' , 'IL')
insert into US_States values ( 'Indiana' , 'IN')
insert into US_States values ( 'Iowa' , 'IA')
insert into US_States values ( 'Kansas' , 'KS')
insert into US_States values ( 'Kentucky' , 'KY')
insert into US_States values ( 'Louisiana' , 'LA')
insert into US_States values ( 'Maine' , 'ME')
insert into US_States values ( 'Maryland' , 'MD')
insert into US_States values ( 'Massachusetts' , 'MA')
insert into US_States values ( 'Michigan' , 'MI')
insert into US_States values ( 'Minnesota' , 'MN')
insert into US_States values ( 'Mississippi' , 'MS')
insert into US_States values ( 'Missouri' , 'MO')
insert into US_States values ( 'Montana' , 'MT')
insert into US_States values ( 'Nebraska' , 'NE')
insert into US_States values ( 'Nevada' , 'NV')
insert into US_States values ( 'New Hampshire' , 'NH')
insert into US_States values ( 'New Jersey' , 'NJ')
insert into US_States values ( 'New Mexico' , 'NM')
insert into US_States values ( 'New York' , 'NY')
insert into US_States values ( 'North Carolina' , 'NC')
insert into US_States values ( 'North Dakota' , 'ND')
insert into US_States values ( 'Ohio' , 'OH')
insert into US_States values ( 'Oklahoma' , 'OK')
insert into US_States values ( 'Oregon' , 'OR')
insert into US_States values ( 'Pennsylvania' , 'PA')
insert into US_States values ( 'Rhode Island' , 'RI')
insert into US_States values ( 'South Carolina' , 'SC')
insert into US_States values ( 'South Dakota' , 'SD')
insert into US_States values ( 'Tennessee' , 'TN')
insert into US_States values ( 'Texas' , 'TX')
insert into US_States values ( 'Utah' , 'UT')
insert into US_States values ( 'Vermont' , 'VT')
insert into US_States values ( 'Virginia' , 'VA')
insert into US_States values ( 'Washington' , 'WA')
insert into US_States values ( 'West Virginia' , 'WV')
insert into US_States values ( 'Wisconsin' , 'WI')
insert into US_States values ( 'Wyoming' , 'WY')
GO
Posted in SQL Server |
3 comments

October 22 2008 by

admin
Its been a while since I had a new post. Mainly because I've been working on an awesome Flex application for the Fleet Leasing Company where I work.
About 3 months ago I got a Yahoo Widget that reads the NYMEX for Light Sweet Crude and posts the price to my desktop ever 20 minutes or so. The owner of my company comes over a couple times a week and checks it out. Today he asked me to create one for our client website. So the cfc I made now drives the pod. Here is the code:
The CFC
<cfcomponent>
<cffunction name="getOilPrice" access="public" returntype="string">
<cfargument name="firstCatch" type="string" default="#HTMLEditFormat('<span class="tbl_num">')#">
<cfargument name="lastCatch" type="string" default="#HTMLEditFormat('</span>')#">
<cfargument name="crudeURL" type="string" default="http://www.bloomberg.com/markets/commodities/energyprices.html">
<cfhttp url="#arguments.crudeURL#" resolveurl="Yes" throwOnError="Yes"/>
<cfset nymex = #CFHTTP.FileContent#>
<cfset firstDmp = '#mid(nymex, 1, val(find(arguments.firstCatch, nymex, 0) + val(len(arguments.firstCatch)-1)))#'>
<cfset leftNYMEX = ReplaceNoCase(nymex, firstDmp, '')>
<cfset secondDmp = '#mid(leftNYMEX, 1, val(find('.', leftNYMEX, 0) + 2))#'>
<cfset newNYMEX = secondDmp>
<cfreturn newNYMEX>
</cffunction>
</cfcomponent>
The Pod
<cfsetting enablecfoutputonly='true'>
<cfprocessingdirective pageencoding='utf-8'>
<cfmodule template='../../tags/podlayout.cfm' title='NYMEX Crude Oil Price'>
<!---
Your Pod text goes here -
Remember it has to be in cfoutput
tags or it will not be displayed
--->
<cfinvoke component="components.nymex" method="getOilPrice" returnvariable="newNYMEX">
<cfinvokeargument name="firstCatch" value='<span class="tbl_num">'>
<cfinvokeargument name="lastCatch" value='</span>'>
<cfinvokeargument name="crudeURL" value="http://www.bloomberg.com/markets/commodities/energyprices.html">
</cfinvoke>
<cfoutput>
<div align="center">NYMEx Crude Oil Price as of:</div>
<div align="center">#dateFormat(now(), 'mmm/dd/yy')# #timeFormat(now(), 'HH:MM')#</div>
<div align="center">#dollarFormat(newNYMEX)#</div>
</cfoutput>
</cfmodule>
<cfsetting enablecfoutputonly='false'/>
Feel free to use it, but don't be like
Ray Horn and not pay homage to my greatness.
Created by Christopher Walker - www.SharedDynamics.com
Posted in BlogCFC Pod Goodies |
5 comments