Posted: April 25th, 2013 | Author: Christopher Vigliotti | Filed under: ColdFusion, Frameworks, MVC | 2 Comments »
What does this ColdFusion developer do in his spare time? If you answered ‘write a custom MVC framework in two hours’ then you answered correctly. Initially I hesitated to share this, as it is nowhere close to finished (and probably never will be). But I decided to throw caution to the wind and offer it up for ridicule and scrutiny. Here’s a list of what I was able to accomplish in two hours…
- Create a spiffy directory structure
- Add model, view and controller logic
- integrate jquery, datatables.net and bootstrap (although I do get a warning when datatables loads)
- Create a controller layer that allows for persistant variables when forwarding to one action to the next (like the flash scope in Grails)
If I were to spend any more time on this project I would explore
- Moving the controller layer to cfcs
- Switching from a [url]?action=section.action convention to a [url]/section/ation/ convention
- Integrate ColdFusion’s built-in ORM goodness to the model
- Actually make the sample application to work (adding CRUD features for the ‘widget’ entity)
- Switching out the awesome Bootstrap front-end framework for the even more awesome Foundation front-end framework
If you are looking for a good ColdFusion framework I insist that you look elsewhere. ColdBox, CFWheels, FW/1 and Model Glue are all really good.
Without further rambling I present the 0.2 release of Widgets Ahoy!
Posted: December 20th, 2012 | Author: Christopher Vigliotti | Filed under: ColdFusion | 2 Comments »
Hello once again ColdFusion fans. I wish I had more time to blog about my adventures over the last six months (there have been many), but alas I do not. I was able to take a few minutes to share this with you, hope you find it helpful…
One of the reasons why I love ColdFusion is that it allows me to solve problems quickly. Today I ran into an issue where we had to move to a new mail server. I had HUNDREDS of email messages in the undelivered folder that needed to be re-sent after the move was completed.
After moving to the new mail server and attempting to move the messages to the Spool folder the messages kept re-appearing in the undelivered folder. Even though I specified a new mail server in ColdFusion Administrator the old messages were still tied to the old server and were bouncing back.
So I wrote this code to solve the problem. Feel free to co-opt it, take full credit for it, add this feature to Ray Camden‘s SpoolMail project (I did swipe a few lines of his code from SpoolMail for this) or get a face tattoo of the source code.
<cfscript>
// declare variables
request.emailMessage = "";
request.maildir = server.coldfusion.rootdir & "/Mail/Undelivr/";
request.messagesListQuery = "";
request.newMailServerAndPort = "new.servername.goes.here:25";
request.oldMailServerAndPort = "old.servername.goes.here:25";
request.spooldir = server.coldfusion.rootdir & "/Mail/Spool/";
</cfscript>
<!--- get the undelivered messages --->
<cfdirectory action="list"
name="request.messagesListQuery"
directory="#request.maildir#"
filter="*.cfmail"
sort="datelastmodified desc">
<!--- loop through the list of messages --->
<cfoutput query="request.messagesListQuery">
<!--- read a message --->
<cffile action="read" file="#request.maildir#/#name#" variable="request.emailMessage">
<!--- if the old mail server is present in the email... --->
<cfif FindNoCase(request.oldMailServerAndPort,request.emailMessage)>
<!--- ...then swap it out with the new mail server --->
<cfset request.emailMessage =
ReplaceNoCase(request.emailMessage, request.oldMailServerAndPort, request.newMailServerAndPort) />
<!--- write the file to the spool directory + delete the old message --->
<cffile action="write" file="#request.spooldir#/#name#" output="#request.emailMessage#">
<cffile action="delete" file="#request.maildir#/#name#">
</cfif>
</cfoutput>
<!--- display the results --->
<cfoutput>
#request.messagesListQuery.recordcount# messages that were set to be delivered to server
#request.oldMailServerAndPort# have will now be re-sent using server
#request.newMailServerAndPort#. Have a nice day.
</cfoutput> |
Once again ColdFusion helped me to quickly solve a problem. Face tattoo sold separately.
Posted: October 9th, 2012 | Author: Christopher Vigliotti | Filed under: ColdFusion | No Comments »
UPDATE: We’re no longer accepting applications or other correspondence for this position.
The small, fast-paced educational startup where I work is hiring! We’re busy, we’re growing and are we’re looking for an exceptional developer who wants to build something great. I’m looking for a world-class senior-level ColdFusion and SQL Server Developer. Do you…
have 7+ years of solid experience with ColdFusion and SQL Server?
have experience with ColdFusion frameworks?
have the drive to work remotely?
have the skill to work with a small team on both on legacy and new ColdFusion-based systems?
If you answered yes to the above four questions and are interested in a change then please send your resume in Word format via email to cvigliotti@presassociates.com with the characters ‘CFJOB’ in the subject. At this point this is a contract-level position and I am not accepting resumes from third parties of any kind. Thanks!
Posted: July 23rd, 2012 | Author: Christopher Vigliotti | Filed under: ColdFusion | No Comments »
My quest to be the last developer to blog about ColdFusion 10 is over! This will come as news to nobody in the community, but ColdFusion 10 is here. I’m looking forward to checking it out, and am particularly interested in tinkering with the enhanced ORM goodness (which I have exposure to in Groovy/Grails). I’m also glad to see Adobe pair ColdFusion 10 up with Solr and Tomcat. Go ColdFusion!
Posted: January 18th, 2012 | Author: Christopher Vigliotti | Filed under: ColdFusion | 2 Comments »
I’ll be participating on a preview of ColdFusion Zeus tomorrow at noon. See you there.
Posted: October 5th, 2011 | Author: Christopher Vigliotti | Filed under: ColdFusion | 1 Comment »
Welcome to what may quite possibly be my laziest blog post ever…in which I mention the new version of ColdFusion in the title and simply state that “I’m seeing some juicy details on the new version of ColdFusion…head over to Nathan Struz‘s twitter feed now for more”. Enjoy.
Posted: September 6th, 2011 | Author: Christopher Vigliotti | Filed under: ColdFusion | No Comments »
Imagine if you could define the relationships between entities in your data-driven system once, and then have them automatically link to both the database and to the display pages of your ColdFusion-based system. I’m exploring this concept now and am calling it “Entity Drive”.
The Point
The high-level goal here is to speed up the process of developing software. Every system that I’ve coded shares similar features. Entity Drive automates the process of some of those features…in particular getting data from the database, displaying it (either in list or tree forms) and presenting users with system interactions. I should also point out that the code is easy read, implement and modify.
Concepts
Entity Drive is similar to existing Object-relational mapping (ORM) solutions in that it links the database to system objects. Unlike ORM the code uses a structure in place of objects. I chose a structure or structures in place of objects as I want this to work as fast as possible. This structure is called the Entity Definition.
Each Entity Definition includes four basic pieces:
- it’s name
- how it relates to the database
- how it relates to child entities
- which (if any) links to create
From the Entity Definition you simply pass in ancestor and descendent entity names and generate an Entity Chain. An Entity Chain is a slice of the Entity Definition that only contains relevant segments of the Entity Definition. It is limited to definitions of the ancestor entity, the descendent entity and each entity between.
The Entity Chain serves two purposes. The first is to generate queries. The second is to generate views. Both are dynamically generated, which is a fancy way of saying that they are created when and where you need them.
Where I’m At
It works and it’s fast. I have the following features working:
- Entity Definition created from an XML file
- Entity Chain created from Entity Definition
- queries are dynamically generated
- a basic Tree View feature that outputs the query
What’s Next
- refine Tree View feature to restore the tree’s expand/collapse state when a user returns to the page
- highlight relevant tree node when user returns
- refactor Entity Drive, Entity Chain and Entity DAO objects, adding lots and lots of comments
- create unit tests and functional tests for all features
- perform testing with a mega-huge data set
- create an awesome List View page
- documentation, documentation, documentation
In the coming weeks/months I’ll be posting updates and code samples. When it’s done I’ll share it.
Posted: September 6th, 2011 | Author: Christopher Vigliotti | Filed under: ColdFusion | 2 Comments »
I ran across the following error when attempting to add an array to a structure: “Complex object types cannot be converted to simple values”
<cfscript>
request.anArray = ArrayNew(1);
request.aStruct = StructNew();
request.aStructure = request.xml.entity.xmlAttributes;
request.aStructure.aString = "must...drink...coffee...";
// interestingly enough this does not throw an error
request.aStructure.aStruct = request.aStruct;
// boo hoo, an error :(
request.aStructure.anArray = request.anArray;
</cfscript> |
It’s important to note that I am copying structure elements from an xml node. When I remove the reference to xmlAttributes the error vanishes.
<cfscript>
request.anArray = ArrayNew(1);
request.aStruct = StructNew();
request.aStructure = StructNew();
request.aStructure.aString = "must...drink...coffee...";
request.aStructure.aStruct = request.aStruct;
// no error this time. hmm...
request.aStructure.anArray = request.anArray;
</cfscript> |
Since I needed to get values from xml I was still up against the error. After a few moments of scratching my head I wrapped the xml in ColdFusion’s Duplicate() method.
<cfscript>
request.anArray = ArrayNew(1);
request.aStruct = StructNew();
// booya
request.aStructure = Duplicate(request.xml.entity.xmlAttributes);
request.aStructure.aString = "must...drink...coffee...";
request.aStructure.aStruct = request.aStruct;
request.aStructure.anArray = request.anArray;
</cfscript> |
ColdFusion’s Duplicate() function to the rescue! The above code does not throw an error, and I am able to get the xml values that I need as well as add arrays to the structure.
I am left wondering if this is a bug in ColdFusion 8. It would appear so to me. At some point I will test this in ColdFusion 9 to see if I get the same results.
Posted: August 18th, 2011 | Author: Christopher Vigliotti | Filed under: ColdFusion, jQuery | 1 Comment »
Most ColdFusion developers are using either ColdFusion Builder or Eclipse (with added CFEclipse awesomeness). I’m presently using CFEclipse for ColdFusion development, but when I have to create HTML prototypes I use Adobe Dreamweaver. This morning I leveraged Dreamweaver’s templates and jQuery code completion features to get an ajax-powered, interactive prototype up and running in an hour.
I’m wondering why the folks at Adobe didn’t just add some of ColdFusion Builder’s awesome features to Dreamweaver.
Posted: August 17th, 2011 | Author: Christopher Vigliotti | Filed under: ColdFusion | No Comments »
Is this really my first post since June?! At any rate here’s a simple tip that may save some of you some time. Here is a CFEclipse Snippet for quickly writing get and set methods.
<!--- get$${Uppercase Property Name} --->
<cffunction name="get$${Uppercase Property Name}"
output="false"
access="public"
returntype="$${Return Type:any|void|string|numeric|struct|array|query}"
hint="get method for $${Lowercase Property Name}">
<cfreturn variables.$${Lowercase Property Name} />
</cffunction>
<!--- set$${Uppercase Property Name} --->
<cffunction
name="set$${Uppercase Property Name}"
output="false"
access="public"
returntype="void"
hint="set method for $${Lowercase Property Name}">
<cfargument name="$${Lowercase Property Name}"
type="$${Return Type:any|void|string|numeric|struct|array|query}"
required="true"
hint="set method for $${Lowercase Property Name}" />
<cfset variables.$${Lowercase Property Name} = arguments.$${Lowercase Property Name} />
</cffunction> |