Skip to main content

Posts

Showing posts with the label cfml

Several options for providing query parameters to 'queryExecute' function

The params argument of the queryExecute() function can be passed in a number of forms.  Using an object or a structure will allow named query parameters, while the array method necessitates the question mark (?) placeholders. Because of this difference, the SQL variable has been defined twice, once in each manner.  The query is run and the result is dumped in the final example. Object and structure methods // Params definition option 1. var sqlParams =     {         firstParam: "FIELD VALUE",         secondParam: "FIELD VALUE"     } // Params definition option 2. var sqlParams = structNew (); sqlParams . firstParam = "FIELD VALUE" ; sqlParams . secondParam = "FIELD VALUE" ; // Params definition option 3. var sqlParams = structNew (); sqlParams [ "firstParam" ] = "FIELD VALUE" ; sqlParams [ "secondParam" ] = "FIELD VALUE" ; var sql = "     declare @retur...

Public versus private properties in CFML

It's not immediately clear how to differentiate between public and private properties in CFML CFC s (ColdFusion Components, which in turn are classes).  Defining methods is more straightforward, in that they provide for public and private keywords to signal their scope.  It would stand to reason that these scoping keywords might also be applicable for properties as well.  After all, this is the approach taken with other languages such as Java and PHP . Alas, it is not the case.  And to compound matters, searching the Web doesn't really provide much clarification on the matter either.  Answers range from, it's just not possible, to initializing variables in the constructor to make them act like private properties. The examples provided here bear out that, CFML, at least running on Railo / Lucee , do in fact, support the scoping of properties.  It works like this.  Properties intitialized using the this.variableName form are public.  Simply i...

Tag syntax argument is invalid complaint against CFML

A common gripe amongst ColdFusion detractors is its tag-based syntax.  And to be honest, who could blame them?  There is an endless collection of CFML code on the Internet that uses CF tags instead of CFScript notation.  This, in spite of CFML's support of script-based syntax since 1998 .  Granted, the provision was limited until version 9 , but that was 4 years ago. While some developers like the tag-style syntax, for those who don't it's easy to understand why the perception is that this is how CFML applications are coded. The following examples are comparing straight CFML with CFScript and are taken from Adobe's own help page. About CFScript http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec0a0e0-7ffe.html First using CFML <cfif IsDefined("Form.submit")> <cfif (Form.lastname NEQ "") AND (Form.department NEQ "")> <cfset employee = structnew()> <cfset employee.firstna...

Adding support for path_info to Tomcat

By default Apache Tomcat does not come configured to handle the path_info server variable information commonly found in SES (search engine safe) compatible URLs.  An SES URL might look like:  www.domain.tld/index.cfm/user/123 .  Combining Tomcat as the servlet container with other technologies like Railo and Mura , this missing feature can become problematic and frustrating (redundancy provided for emphasis). A scenario The path_info data is traditionally available to CFML applications a la the CGI.path_info variable.  Applications often refer to this variable to resolve URLs to specific actions or details of the application.  One such example is Mura.  The CMS (content management system) has the ability to host several sites from a single instance of the application.  While most sites are likely set up to be accessed from their own domain names, in some cases, the sites will be accessed through an identifier in the URL.  For example, as...