Jul
10
ColdFusion
· By Michael Ferguson
After creating a non-flashᅠCFREE in ColdFusion8 and clicking on an expandable branch (only tested with the top branch), the browser receives an error on line 248 stating that 'style' is null or not an object.ᅠ You could dig through all your code all you want, but it isn't your line 248 error.
If you investigate the following folder in your ColdFusion web-root "CFIDE\scripts\ajax\package\" and open the "cftree.js" file you'll discover the bit of bad code that escaped the quality inspection effort before delivery to production.ᅠ The actual error is on line 247 where it calls _68.style.backgroundColor="lightblue"; which should mean when you select the branch it will turn the background color a light blue by default.
So what's the problem?ᅠ Why the error?ᅠ This line of code is fine; it's not mal-formed at all.ᅠ The real problem is that it is out of place.ᅠ Take a look above this code and lines 244-245, these lines of JavaScript deal with testing the existence of objectᅠ_68, which will govern if a style can be applied.ᅠ Line 247 is not obeying the script's error handling and must be corrected.
The easiest thing to do is just remark out the line and press on with life, the light blue is forced upon you anyway and chances are it will not conform to your design style and color scheme.ᅠ Commenting out the problem on line 247 has no ill side-effects; there are no other errors just a cooperative CFTREE.
If you find this post useful please leave a comment and let me know how you used the information.
Jul
3
ColdFusion
· By Michael Ferguson
The browser throws an error durring execution of a CFC page: "Exception thrown and not caught" the offending page is "cfajax.js" in the folders "CFIDE\scripts\ajax\package", specifically line 803. Careful investigation leads you to an offending HTML comment that lands into the CFC thanks to an Application CFM inclusion.ᅠ The easy route might be to rid the file of all comments, but if the code isn't just for yourself and you must have those comments in place here is a workaround for you.
Simply surround each set of comments with a conditional statement to determine the file extension of the current file.ᅠ If the condition tests the file name and determines that it isn't a CFC, then the comments are included.
Example:
<cfif Right(CGI.SCRIPT_NAME, 4) NEQ ".cfc">
</cfif>
If you find this post useful please leave a comment and let me know how you used the information.
Jul
3
ColdFusion
· By Michael Ferguson
If we want to use AJAX so that the visitor can remain on the same page while the search parameters are continuously refined, then the AUTOSUGGEST attribute of the CFINPUT tag can be utilized. This way when requesting the user to provide data it makes it easier to pull consistent statistics from that data when it is uniform. If many of the appointment remarks are going to start off with the same phrase, then we don't necessarily want to make them type that portion over and over.
<cfform>
<cfinput type="text" name="AppointRemark" autosuggest="cfc:SuggestAppointRemark.getSuggest({cfautosuggestvalue})" maxresultsdisplayed="15" showautosuggestloadingicon="false" />
</cfform>
The AUTOSUGGEST triggers the SuggestAppointRemark CFC, specifically the getSuggest function, sending it the text typed into the AppointRemark field in our CFM page. As the letters are typed, the GetRemark query is populated with the information and returns an array of possibilities (limited to 15 in this example by the MAXRESULTSDISPLAYED attribute of the CFINPUT tag). If you add the matchcontains="true" attribute into the CF INPUT you will get a list containing the letter groups you type into the field instead. That is fine for short lists, but can be cumbersome for longer lists of information.
<cffunction name="getSuggest" access="remote">
<cfargument name="SuggestRemark" type="string" required="true">
<cfset var GetRemark="">
<cfscript>
GetRemark=QueryNew("Remark");
QueryAddRow(GetRemark, 4);
QuerySetCell(GetRemark, "Remark", "Apples", 1);
QuerySetCell(GetRemark, "Remark", "Almonds", 2);
QuerySetCell(GetRemark, "Remark", "Alaska", 3);
QuerySetCell(GetRemark, "Remark", "Aladin", 4);
</cfscript>
<cfreturn ListToArray(ValueList(GetRemark.Remark))>
</cffunction>
When you run the form and type the letter A in the field, you will be presented with a list of all possibilities in our pseudo database. Add the letter L and the list drops off Apples. Add the letter A and the list drops off Almonds.
If you find this post useful please leave a comment and let me know how you used the information.
Jun
28
ColdFusion
· By Michael Ferguson
Although I have Googled the Earth to a great extent, I could not find a straight forward method in which to use the CFWINDOW as a replacement for the JavaScript confirm-alert box. In this example, the replacement could used as a Custom Tag but was written to explain how to call and execute.
First is the test form we will use to gather and submit data.
<cfdump var="#FORM#">
<form action="<cfoutput>#CGI.SCRIPT_NAME#</cfoutput>" method="post" name="TestForm">
<input name="TestData" type="hidden" />
<input name="TestSubmit" type="submit" onClick="fnAlertBox(this); return false;" />
</form>
The CFDUMP will confirm if the data is being passed, the form is submitting to itself and the submit button has been set to stop (or return false) to force the rest of the code to execute. If you leave off this part, the form will automatically submit when the button is depressed.
Next we will need to include some code on the page before the form to handle calling the CFWINDOW and giving the user a choice.
<cfif StructKeyExists(URL, "AlertBox")>
<div class="AlertBox">
Are you sure you want to do that?<br /><br />
<input name="AlertBoxYes" type="button" value="YES" onClick="fnConfirm('<cfoutput>#URL.AlertBox#</cfoutput>');" />
<input name="AlertBoxNo" type="button" value="NO" onClick="ColdFusion.Window.hide('AlertWindow');" />
</div>
<cfabort>
</cfif>
In this example I am calling the CFWINDOW and building the CFWINDOW contents with the same file by checking for the existence of a URL variable. The two choices presented will be a YES and a NO. No will simply cancel the box and since we have already issued a return false from the form, the visitor can continue with edits or make a new selection. YES will receive the name of the form field (dynamically through JavaScript so we don't have to hard code a form name).
<cfsavecontent variable="head">
<style type="text/css">
@import "/CFIDE/scripts/ajax/ext/resources/css/xtheme-aero.css";
.AlertBox, .AlertBox INPUT {
font: Verdana, Geneva, sans-serif;
font-size: 16px;
font-weight: normal;
color: #000;}
.AlertBox {
height: 100%;
overflow: hidden;
text-align: center;
background: #96B9E6;}
.AlertBox INPUT {
width: 80px;}
</style>
</cfsavecontent>
<cfhtmlhead text="#head#">
As a suggestion, the style statements are interjected to make the CFWINDOW more pleasant.
<script type="text/javascript">
function fnWinCleanUp() {
ColdFusion.Window.destroy("AlertWindow", true);}
function fnAlertBox(obj) {
try {
ColdFusion.Window.destroy("AlertWindow", true);}
catch(e) { }
ColdFusion.Window.create("AlertWindow", "Confirm?", "cfConfirmBox.cfm?AlertBox=" + obj.form.name, {width:250,height:110,modal:true,closable:false,draggable:false,resizable:false,center:true});
ColdFusion.Window.onHide("AlertWindow", fnWinCleanUp);}
function fnConfirm(obj) {
document.forms[obj].submit();}
</script>
<cfajaximport tags="cfwindow, cfdiv">
The function that handles the YES button submits the form thanks to the URL variable sent to it from the form submit button.
If you find this post useful please leave a comment and let me know how you used the information.
Jun
12
ColdFusion
· By Michael Ferguson
A few years ago an update to Internet Explorer and "Active X activation issues" caused a bounding box to be displayed around all flash objects. I needed to come up with a solution to bypass the imposed requirement for customers to click on the OBJECT tag to activate.
I chose the SWFObject as a work around but it meant re-writing every page with a hardcoded fix. Not a good plan for a corporate web-presence that was at the very core of its mission execution.
Here is a link to SWFObject.
The solution was to design a custom tag that would detect which was the first SWF on the page and include the SWFObject call to load the JavaScript. Using the custom tag CALLER scope and counting how many times the custom tag is called per page, the code below adds the JavaScript on the first call and skips past each subsequent call. This way the page doesn't return multiple functions with the same name, reduces clutter, speeds up processing, and delivers content with control over the SWF attributes...all without hard coding pages.
<cfparam name="CALLER.cfFlashMX" default="0">
<cfparam name="ATTRIBUTES.FlashHeight" default="0">
<cfparam name="ATTRIBUTES.FlashWidth" default="0">
<cfparam name="ATTRIBUTES.FlashVersion" default="10.0.45.2">
<cfparam name="ATTRIBUTES.FlashColor" default="FFFFFF">
<cfparam name="ATTRIBUTES.FlashWMode" default="transparent">
<cfset CALLER.cfFlashMX=CALLER.cfFlashMX+1>
<cfif CALLER.cfFlashMX EQ 1>
<script type="text/javascript" src="/Media/fnSWFobject.js"></script>
</cfif>
<cfoutput>
<script type="text/javascript">
var so#CALLER.cfFlashMX# = new SWFObject("#ATTRIBUTES.FlashFile#", "#ATTRIBUTES.FlashName#", "#ATTRIBUTES.FlashWidth#", "#ATTRIBUTES.FlashHeight#", "#ATTRIBUTES.FlashVersion#", "#ATTRIBUTES.FlashColor#");
so#CALLER.cfFlashMX#.addParam("wmode", "#ATTRIBUTES.FlashWMode#");
so#CALLER.cfFlashMX#.addParam("menu", "false");
so#CALLER.cfFlashMX#.write("flashcontent#CALLER.cfFlashMX#");
</script>
</cfoutput>
This example called SWFObject v1.5 when it was originally designed.
If you find this post useful please leave a comment and let me know how you used the information.