Web Trenches
Lucee Logo

Tips for Moving from Adobe ColdFusion to Lucee



I have moved well over 100 websites and applications from Adobe ColdFusion to Lucee servers over the past few months. While 95% of the code is cross-compatible and works right away, I have run into a few things that I thought I should share. This is not meant to be a comprehensive list of incompatibilities between Adobe CF and Lucee. You can get a list of differences from the Lucee docs. This is really just a bunch if tips and solutions for common issues.  I will probably write separate articles about some of them.

First, a bit of a disclaimer… I am not proposing the solutions below as the BEST solution to the issue. In most cases, I am not in a position to re-engineer the code. My job has been to get websites that are running old ColdFusion code over to Lucee in the most efficient way. If I were able to rebuild these sites or applications, I would not have taken the same approach in many cases.

CFGRID

Hindsight is always 20/20. We should never have invested in this tag, or really any of Adobe’s Ajax-based tags. For some reason, back in the 00s, we loved CFGRID and used it all over the place. Rather than rewrite every implementation across hundreds of files to use a different technology, I decided to write a CFGRID alternative tag and install it on Lucee. It still required minor adjustments to existing CFGRID code, but it probably saved weeks of programming time. CFGRID-Lucee is available here on GitHub: https://github.com/spraguey/cfgrid-lucee

CFWINDOW, CFDIV, AND CFTOOLTIP

Luckily, I did not encounter many of these. I had to manually update the code for these to use an independent (of Lucee) solution. Most of the sites I work on have jQuery already on them, so here are the alternatives I used.

  • CFWINDOW – jQuery UI Dialog
  • CFDIV – There isn’t really much use in this tag. They can be changed to simple DIV tags and then you can use jQuery or any other library for working with the DOM.
  • CFTOOLTIP – If you already have jQuery UI loaded, then the UI Tooltip is the way to go. If you don’t want the expense of loading UI, then Tooltipster is a nice solution.

CFPDFFORM

Adobe built a lot of custom functionality into ColdFusion for PDF manipulation. This is not in Lucee by default, but MitrahSoft wrote a nice alternative CFPDFFORM tag for Lucee.
https://github.com/MitrahSoft/lucee-cfpdfform

You may run into some font issues if your source PDF has Adobe-licensed fonts in it – such as Helvetica. If you do, you will need to open up the source document in Acrobat DC and change those fonts to an OpenType font. Otherwise, you will get errors.

CFSELECT with Bind attribute

CFSELECT does work in Lucee, but the bind attribute is not supported. There is no easy solution for this, so I had to convert these to the way it was done prior to Adobe introducing bind. I used regular HTML and CFML (CFQUERY/CFOUTPUT) for simple list population, and Ajax calls to return dynamically populated select boxes. Paul Underwood has a good example of the Ajax method.

CFINPUT type=”datefield”

This is not supported in Lucee. In most cases, I simply changed these to <input type=”date”>, which is handled okay by any HTML5-capable browser. In cases where I thought the interface was important, I used a JavaScript datepicker, such as jQuery UI Datepicker or Fengyuanchen’s datepicker.

CFINPUT with an ID attribute

This one was difficult to pinpoint at first.  In Adobe CF, the code <cfinput name=”myfield” type=”text” /> actually generates the following HTML: <input name=”myfield” id=”myfield” type=”text” />. It automatically places the ID attribute in there for you. Lucee does not do this. It must be manually specified. Why is this important? In many cases, there was JavaScript in our applications that referred to the field by its ID. All of that JavaScript broke when it was switched to Lucee. There were over 1,500 instances of this across our websites. I did a bulk update of all of the code using Sublime Text and a regular expression replace.

  • Sublime Text > Find > Find in Files…
  • Find: (<(?:cfinput|cfselect|cfform)(?![^>]+\bid\s*=)[^>]*?(?:\bname\s*=\s*[“‘]?((?:[^\t\n\f \/>”‘=#]+|#[^#]+#)+)[“‘]?\s*))([^>]*?>)
  • Where: Specify your folder(s). For example: c:\webspace,*.cfm,*.cfc
  • Replace: $1 id=”$2″ $3This will go through all of your files and add the id to any cfinputs. The beauty of this replace is that it will only add the ID if there isn’t currently an ID on the tag.

CFINPUT Validation Errors

There were two validation types that caused problems for us.

  • cfinput validateAt=”onServer,onSubmit”
    Just remove these. Lucee handles the validation correctly and they are not necessary. I used Sublime Text as described above, and replaced them all with an empty string.
  • cfinput type=”submit” validate=”submitonce”
    I had to remove these, and prevent duplicate submissions using JavaScript manually.

CFSEARCH type=”dismax”

This search type does not exist in Lucee. These can be changed to type=”simple”, which doesn’t have much impact on the results.

CFFILEUPLOAD

This is not in Lucee. Hopefully you didn’t use this much, because there is no simple solution here. These need to be re-coded using CFFILE and HTML upload fields.

File size uploads

In Adobe CF, the maximum uploadable file size can be  specified in the ColdFusion Administrator.  This is not the case in Lucee. If you are on a Windows server, Lucee uses the IIS upload size restrictions. I wrote an article about adjusting this in IIS7. In newer versions of IIS, it may also be necessary to do this at the site level. This article was the best summary for IIS 7.5+.

CFHTTP Get and CFHTTPPARAM

If you are doing a CFHTTP get operation, you can’t pass the URL variables in as CFHTTPPARAMs.

Instead of this…

<cfhttp method="get" url="myfile.cfm>
   <cfhttpparam name="myvar" value="myvalue" />
</cfhttp>

Do this…

<cfhttp method="get" url="myfile.cfm?myvar=#myvalue#" ></cfhttp>

[EDIT based on comment below. The proper way is:]

<cfhttp method="get" url="myfile.cfm>
   <cfhttpparam name="myvar" value="myvalue" type="URL" />
</cfhttp>

CFHTTP and Basic Authentication over SSL

With cfhttp calls that use SSL and Basic authentication, you cannot pass the username and password in the attributes of the <cfhttp> tag. They need to be passed as headers.

<cfhttp url="https://what.ever.com" username="myusername" password="123">

should be converted to

<cfhttp url="https://what.ever.com">
  <cfhttpparam type="header" name="Authorization" value="Basic #ToBase64( 'myusername:1234' )#" />
</cfhttp>

CFTEXTAREA

If you use this with richtext=”true”, you are out of luck. You’ll need to use a library for WYSIWYG editing. If you used it just as a simple form element, then you have two choices. You could go through and update them all to simple <textarea>. Keep in mind, thought, that if you had variables in any of the attributes then these have to be inside of <cfoutput> tags. An alternative is to use this replacement tag for CFTEXTAREA on the server side, which handles all that logic for you. No change to your code is needed in this case.

URL/Form Values as an Array, not a List

This one is hard to explain without an example.

my-file.cfm?id=1&id=2&id=3

In Adobe CF, url.id would come through as 1,2,3. In Lucee, it comes through as an ARRAY of values that you need to loop through to get the results. <cfloop list=”#url.id#”> becomes <cfloop array=”#url.id#”>

You might ask… why would you ever do this anyway? Well, jQuery UI sortables will come through this way when submitted via Ajax.

[EDIT: My example is a poor one. It should be as follows. Sortables adds the [] to the variables and that triggers the issue. The original example above actually works fine in Lucee.]

my-file.cfm?id[]=1&id[]=2&id[]=3

ODBC Text Datasources

The drivers needed for the JDBC-ODBC bridge are not included in Java 8. If you need to use the bridge, you’ll have to extract them from a Java 7 install and put them in your Java 8 that is used for Lucee. I recently wrote an article that covers this.

Whew!

That seems like a lot of stuff! Hopefully this does not scare you away from switching over to Lucee. It really is a great engine and runs MUCH faster and more stable than Adobe CF in my experience.

7 Replies to “Tips for Moving from Adobe ColdFusion to Lucee”

  1. Great post, we will look to address this issues, sometimes to best way to get an issue fixed us to raise a ticket for it 😉
    http://issues.lucee.org

    CFHTTP GET AND CFHTTPPARAM
    this works with Lucee but you have to define the attribute “type”
    http://trycf.com/gist/c47395a59f1b4a92c81ac7e72a5b91c7/lucee5?theme=monokai

    Like in the ACF doc as well this attribute is required. we will add “url” as default value for that attribute, now that we are aware of that undocumented feature:
    https://luceeserver.atlassian.net/browse/LDEV-1238

    CFHTTP AND BASIC AUTHENTICATION
    we are not aware of any issues with this, could you raise a ticket with more details (a exception java stacktrace for example). we will look into it.

    URL/FORM VALUES AS AN ARRAY, NOT A LIST
    In Lucee by default you also get a list
    http://trycf.com/gist/e82ff6642676fdf241fc878c04f74839/lucee5?theme=monokai
    but you can change that behaviour in the application.cfc with the setting “sameurlfieldsasarray” and “sameformfieldsasarray”. ACF only supports the last one (sameurlfieldsasarray) maybe you have set both in assumption both are supported?

    ODBC TEXT DATASOURCES
    Interesting, we can make an extension out of that.

    1. Thanks Michael. I will edit my post to clarify some of these, and yes I will raise a ticket if I need to. 🙂 A couple notes in response.

      CFHTTP AND BASIC AUTHENTICATION
      This has been a known issue since Railo, I believe. Here is an example that documents it pretty well: https://issues.jboss.org/browse/RAILO-3315

      URL/FORM VALUES AS AN ARRAY, NOT A LIST
      I may not have given the right info with this, or misunderstood the problem. I am not specifying the behaviour in application.cfc. Here’s an actual example from an app of ours. Sortable sends the following ajax request:
      /manage/ajax/literature.cfm?action=updateorder&brand=2&listitem[]=48EA24C6163C5CF4DB57AA33E4270A82&listitem[]=46890AAB163C5CF4DB2AC5260786F249&listitem[]=57626B56163C5CF4DB5FDD42667A7618

      In ACF, returns a list. In Lucee, it returns an array.

      1. CFHTTP AND BASIC AUTHENTICATION
        i have moved that ticket to here:
        https://luceeserver.atlassian.net/browse/LDEV-1240

        URL/FORM VALUES AS AN ARRAY, NOT A LIST
        yeah, when adding [] add the end of the names, Lucee creates an array.

        Scopes
        ========
        In CFML values of variables that are passed twice in the URL or form scope are converted into lists.

        CFML Example:
        call:index.cfm?test=1&test=2
        cfml:#url.test#
        output:1,2

        It may happen, that a passed value contains commas. This can lead to problems since the separator can not be identified correctly.

        Example:
        call:index.cfm?car=Fiat,Lancia&car=VW,Scoda
        cfml:#url.car#
        output:Fiat,Lancia,VW,Scoda

        In Lucee you have the possibility to pass multiple values of the same variable as an array.

        Example:
        call:index.cfm?car[]=Fiat,Lancia&car[]=VW,Scoda
        cfml:#arrayToList(url.car,”;”)#
        output:Fiat,Lancia;VW,Scoda

        The same is valid for the form scope.
        Password:
        Retype Pw:

  2. To add to what Micha said above, we have also added this ticket as well regarding a setting to limit max file upload sizes:
    https://luceeserver.atlassian.net/browse/LDEV-1239
    And also this ticket as well to support cffileupload:
    https://luceeserver.atlassian.net/browse/LDEV-1237

    I tested the basic auth stuff as well and I see the exact same headers being passed regardless of whether I use the username/password attributes of the cfhttp tag or a custom header so it seems to be working fine for me. Can you confirm exactly what didn’t work for you?

    I also tested the file.cfm?id=1,id=2,id=3 bit and the default settings in Lucee return a list just like Adobe CF. Please confirm you didn’t enable the this.sameurlfieldsasarray setting that Micha mentioned.

    1. Thanks Brad. I clarified those two issues because I didn’t explain them well. The CFHTTP one is over SSL only. The URL issue is only when the URL variable has a [] in it.

      1. Thanks for updating. We didn’t import the Railo bug tracker wholesale into Lucee so that basic auth ticket looks like it got lost. Here’s the new Lucee version:
        https://luceeserver.atlassian.net/browse/LDEV-1240

        Regarding the url fields– it’s a different story if you have the [] in the name 🙂 This is a feature that has been supported in Lucee since Railo 1.0. It is a copy of what PHP does as well. I actually just put in this ticket for Adobe CF to support it:
        https://tracker.adobe.com/#/view/CF-4198416

Leave a Reply

Your email address will not be published. Required fields are marked *