Adding more resource navigator filters to ColdFusion Builder (Eclipse) Redux

There is a post at 12robots.com for how to add resource navigator filters to CFBuilder:

http://www.12robots.com/index.cfm/2010/8/10/Adding-more-resource-navigator-filters-to-ColdFusion-Builder-Eclipse

The solution below is similar, but does not involve accessing .jar files.

Step 1: Locate your version of CFBuilder by selecting “About Adobe ColdFusion Builder 2”.  Make a note of the Version and Build numbers.  For this post I am on Version: 2.0.0 and Build: 277745
Step 2: Locate the plugin.xml file in the com.adobe.ide.coldfusion.rcp_X.X.X.XXXXXX folder (Notice how X.X.X.XXXXXX corresponds to the Version and Build from Step 1):
com.adobe.ide.coldfusion.rcp_2.0.0.277745
Step 2: Locate the following section:
<extension
point="org.eclipse.ui.ide.resourceFilters">

Step 3: Add a block like this for each new filter you want:
<filter
pattern="_notes"
selected="true"/>

Step 4: Start CFBuilder from the command line.  For me on the Mac I execute the following command in Terminal:
"/Applications/Adobe ColdFusion Builder 2/CFBuilder.app/Contents/MacOS/CFBuilder" -clean
Step 5: Enjoy your new navigator filter(s).

Add a last modified date to FW/1 (Framework One) pages

Disclaimer:

  1. I’m a total newb to FW/1.
  2. There is most likely a better, or built in way to do this.

Still with me?  Ok.  Here is the specification for this little ditty:

  1. The site I’m working on is mostly static.
  2. It is required (perhaps legally, definitely procedurally) that every page of the site must have a last modified date in the footer.
  3. The site is built using FW/1 (which is awesome).

Here are the cliff notes of what’s about to go down:

  1. I have a footer that is included in every page.
  2. In the footer view Im going to look at the current page’s action in the request context (rc) and figure out what the corresponding “view” is based on the action
  3. I’m going to use cfdirectory to find the lastmodifieddate of the view file from step 2.

Without further adieu:


<!— Start with the path to our views folder —>
<cfset local.viewPath=”#VARIABLES.FRAMEWORK.BASE#views” />
<!— Make an array of rc.action (we use this to append subfolders) —>
<cfset local.arrAction=ListToArray(rc.action,”.”) />
<!— Set the counter to be 1 short of the action array len b/c the last member will be our view page —>
<cfset local.counter=ArrayLen(local.arrAction)-1 />
<!— Set the last member of our action array to be our action page —>
<cfset local.viewPage=”#local.arrAction[ArrayLen(local.arrAction)]#.cfm” />
<!— Append any subfolders to our viewPath —>
<cfloop from=”1″ to=”#local.counter#” index=”local.a”>
<cfset local.viewPath=”#local.viewPath#/#local.arrAction[local.a]#” />
</cfloop>
<!— Look for our viewPage cfm file in our viewPath —>
<cfdirectory action=”list”
directory=”#ExpandPath(local.viewPath)#”
name=”qGetLastdateModified”
filter=”#ListLast(local.viewPage, “/”)#”>
<!— If we have a record count then calculate the last modified date —>
<cfif qGetLastdateModified.recordCount>
<cfset local.siteLastUpdated=’#DateFormat(qGetLastdateModified.dateLastModified,”long”)# at #TimeFormat(qGetLastdateModified.dateLastModified,”hh:mm:ss tt”)#’ />
<cfelse>
<cfset local.siteLastUpdated=”unknown :- (” />
</cfif>
<cfoutput>#local.siteLastUpdated#</cfoutput>

CAPTCHA Fails

I was buying some software this morning and got the following CAPTCHA at checkout. CLASSIC.

Yup. For real. My other favorite was one I received while working on an application at the office.

Good stuff.

Oracle equivalent of SQL Server SELECT TOP (SELECT TOP n)

I had to do a small update on a site for work with an Oracle back end.  I don’t work with Oracle so I ran into a little snag.  I needed to find the Oracle equivalent of SQL Server’s “SELECT TOP”.  So, here it is:

MS SQL

SELECT TOP 10
field1, field2
FROM
tablename
ORDER BY
field1

ORACLE

SELECT *
FROM
(SELECT
field1, field2
FROM
tablename
ORDER BY field1)
WHERE
ROWNUM <= 10

ColdFusion SOLR error: org/apache/pdfbox/pdmodel/PDDocument null

I got the following pretty obscure error the other day from a cfscheduler job that runs nightly to index documents uploaded to our site:

org/apache/pdfbox/pdmodel/PDDocument null

Turns out that the error is caused by a file having the extension of .PDF instead of .pdf.  No, really. Luckily I only had one offending file, but what if I had many? Also, what if users uploaded more after I renamed the problematic one? There are two parts to “future proofing” my situation. The first part it to address the .PDF extensions in the uploads. The second part, and what I’m going to pass on to you, is a custom tag that will look in a directory you specify and rename all .PDF extensions to .pdf.

To implement:

  • Download the pdf_cleanup custom tag
  • Unzip it to whatever directory you keep you custom tags in
  • Call it using the following syntax just before you run your <cfindex> operation(s):
    <cf_pdf_cleanup dirToClean="C:\mysuperdocs">

Be forewarned I take no responsibility for your use of the tag 😉

Download the pdf_cleanup custom tag

Debugging ColdFusion 9 on shared hosting

With ColdFusion 9 debugging can be enabled on a page by page basis. This is super handy in a shared hosting environment where you don’t have access to the CFADMIN.

Step 1

Set debuggingipaddress and enablerobustexception in the THIS scope of your Application.cfc.  You can use http://www.whatismyip.com if you don’t know your ip address.

	<!--- define a debugging ip --->
	<cfset this.debuggingipaddresses="xxx.xxx.xxx.xxx">
	<!--- enable robust exception --->
	<cfset this.enablerobustexception="yes">

Step 2

Enable show debug output at the top of your page’s code.

	<!--- enable show debug output --->
	<cfsetting showdebugoutput="true">

You should now see your debugging info appended to the page.

Just to verify!

You can verify debugging is enabled by outputting the value of IsDebugMode().

	<!--- Is debugging on?  Should be yes when showdebugoutput="true" --->
	<cfoutput>#IsDebugMode()#</cfoutput>

Saving to a database with ColdFusion using jQuery

A commenter asked me how to extend a previous jQuery post to perform the database save via ColdFusion.  It is REALLY easy (and please keep in mind this is meant to be a SIMPLE example, not production code).  From the jQuery side my example only required the following code to ship the data off to ColdFusion:

function fSave(){
you=$("#you").val();
// Try to save
$.get("adduser.cfm?"+"you="+you , function(data){
// Result
alert(data);
window.location=location.href;
});
}

The adduser.cfm page then validates and inserts the data and returns a success or failure message.

See it hereGet it here.

Use jQuery to enable submit button and set form action

I recently had to do a quick bit of coding to only accept data from a form if JavaScript was enabled.

This example starts with a form that has no action and a disabled submit button.  When jQuery’s .ready() fires though it enables the submit button and attaches the appropriate action.

Please note the example file is in ColdFusion so your mileage may vary slightly for your own use.

See it here | Get it here.

Mac Diff/Merge Utility for Dreamweaver

If you have done web development on a PC in Dreamweaver you have probably used WinMerge to check for differences between local and remote files.  Since I moved to the Mac a few years ago I have been neglectful in finding a similar tool for the Mac.  Thanks to some changes in my current day job I now have a larger team and more of a need for getting my act together on this.

The tool I have decided on in a free one called DiffMerge.  Part 1 of the install is the typical Mac install (drag a file to the Applications folder).  Part 2 is a little more detailed (but dead simple).  There is a readme.txt file in the installer image with instructions for copying 2 files to facilitate command line usage (You will need this for Dreamweaver).

Once you have done the installation and followed the readme.txt fire up Dreamweaver and click Dreamweaver > Preferences > File compare and set the path to your equivalent of the screenshot below:

DiffMerge for Dreamweaver on the Mac