Gregory's Blog

Shorthand struct return

There are many ways to return multiple values from a cfc. Typically we return a query object, a json string, an array, or a structure, but one of my favorite ways to return multiple bits of data is using a shorthand structure. It is much easier and intuitive to use on both the back and front end than using an array. Here is a simple example: Cfc:

<!--- There are two types of routing titles. The original design used an routing title that was used to populate a contract and this title was not the official title, but something more generic that was easily identifiable on a written contract. The other title is the official title that is coming from the workday database We will use the original routing title if the user was assigned a routing title that is found in the routing database, otherwise, we will use the official workday title. --->
<cffunction name="getTitleByEmail" access="remote" returntype="struct"  hint="Determines the approver title. This will be either the routing title that was used in previous contracts, or the official title found in workday. We need to return multiple values, so this returns a one dimension array instead of a string.">
	<cfargument name="email" type="string" required="yes" hint="Supply the email.">
      <cfparam name="title" default="">
      <!---Format the email--->
      <cfinvoke component="#WorkdayUsersObj#" method="formatUwEmail" returnvariable="uwEmail">
      	<cfinvokeargument name="email" value="">
      <!--- Query the Approval database to see if the title exists. --->
      <cfquery name="approvalTitle" datasource="Contracts">
      	SELECT TOP (1)     
		FROM dbo.Approval
		WHERE  (Email = <cfqueryparam value="#uwEmail#" cfsqltype="cf_sql_varchar">) 
      <!---Set the ApproverTitle--->
      <cfset ApproverTitle = approvalTitle.ApproverTitle>
	<!---Get the workday job title. --->
	<cfinvoke component="#WorkdayUsersObj#" method="getEmployeeJobTitle" returnvariable="workdayTitle">
		<cfinvokeargument name="email" value="#email#">
      <!---Build the shorthand struct --->
      <cfset titleStruct = {workdayTitle = #workdayTitle#, ApproverTitle = #ApproverTitle#}>
   <cfreturn titleStruct>

On the client side, simply use the following to output the value:

<cfset thisRoutingTitle = getTitleByEmail(thisApproverEmail).ApproverTitle>
<cfset thisWorkdayTitle = getTitleByEmail(thisApproverEmail).WorkdayTitle>

This entry was posted on December 14, 2018 at 2:34 PM and has received 937 views.

BlogCfc administration

Unfortunately, there is a conflict with BlogCfc's original jQuery UI and Kendo libraries, so I will not be able to incorporate Kendo into the administration section in a timely manner without a complete administration re-write. This decision has an impact the preview of the pods in the administration section. The pods can't be rendered correctly as the Kendo and new jQuery libraries are not available on the administration interface. While I do intend to re-writing the admin section, it is my intention on this first version to focus on different themes, and launch the new BlogCfc with a minimum amount of change. I am hoping that others can quickly install the new blog software and hopefully provide some feedback before the next version. I am going to continue to focus on the client UI and hope to release a .75 version soon without an administrator re-write.

This entry was posted on December 14, 2018 at 12:44 AM and has received 1079 views.

Localization Support Dropped

I am going to forgo using Raymond's localization support for this version. To incorporate a few languages, Raymond uses the resourceBundle.cfc template that was originally coded by Paul Hastings. I believe that it supports two variants Dutch and German languages, along with English of course. Raymond labels his buttons and text messages in the different languages in 4 different .properties files, and uses the 'rb('message var') function to display the text and messages. I have decided not to incorporate the localization as I can't translate between English and the other languages, and this blog is also intended to be a living example how to use Kendo with ColdFusion. Using 'rb('pleaseWait') in my code will be confusing to the reader wanting to know how I am using ColdFusion and Kendo. It is much easier to read:

'$.when({ title: "Please wait...", message: "Searching.", icon: "k-ext-information" }));'


'$.when({ title: "
</cfoutput>", message: "
</cfoutput>", icon: "k-ext-information" }));'

for example. In one of the next versions, if someone wants to assist me in translating the English into the supported languages, I may revisit this decision and incorporate localization into the code.

This entry was posted on December 9, 2018 at 1:15 AM and has received 845 views.

Footer Logo

Your input and contributions are welcomed!

If you have an idea, BlogCfc based code, or a theme that you have built using this site that you want to share, please contribute by making a post here or share it by contacting us! This community can only thrive if we continue to work together.

Images and Photography:

Gregory Alexander either owns the copyright, or has the rights to use, all images and photographs on the site. If an image is not part of the "Galaxie Blog" open sourced distribution package, and instead is part of a personal blog post or a comment, please contact us and the author of the post or comment to obtain permission if you would like to use a personal image or photograph found on this site.


Portions of Galaxie Blog are powered on the server side by BlogCfc, an open source blog developed by Raymond Camden. Revitalizing BlogCfc was a part of my orginal inspiration that prompted me to design this site.


Galaxie Blog Version 3.12 (Toby's Edition) December 10th 2022 Blue Wave Dark theme