Archive for the ‘coldfusion’ Category
Learning Management System?
Note to self: found out today that Todd Sharp has open sourced his application called iLearn. Also found out this sort of application is called Learning Management System.
Similar to what I am working on at the moment with cfexam, but obviously Todd’s one is functional :).
Producing Excel Report in ColdFusion
There are two ways of doing this:
- The hard way
- The POI Utility way
I didn’t do the easy way until now, because I didn’t think it will be that easy.
This is how I did it the hard way:
<cfset lColumns = "job_ref,job_title,firstname,lastname,email,contact_preferred,TrafficLight,location,area,jobType,industry,Occupational"> <cfloop query="qJobs"> <cfoutput> <cfset index = 0> <cfloop list="#lColumns#" index="columnName"> <cfset thisColumn = "qJobs." & columnName> <cfset columnValue = Replace(Evaluate(thisColumn),",","|","ALL")><!--- escape all commas ---> <cfif index gt 0>,</cfif>'#columnValue#' <cfset index = index + 1> </cfloop> </cfoutput> </cfloop>
The template will output the string on the browser
- I will then copy the output, open Notepad and save it as a CSV file.
- Close Notepad, opens the CSV file using M$ Excel and saves it as an Excel file and then I am done.
Ben’s POI Utility does all the above, and it only took me 5 minutes or so to modify his example file, it’s just too easy. Below is the code:
<cfset objPOI = CreateObject( "component", "POIUtility" ).Init() /> <cfset objSheet.Query = qManpower /> <cfset objSheet.ColumnList = lColumns /> <cfset objSheet.ColumnNames = "Job Reference,Job Title, Firstname, Lastname, Email, Contact Preferred, Traffic Light, Location, Area, Job Type, Industry, Occupational Area" /> <cfset objSheet.SheetName = "Sheet 1" /> <cfset objPOI.WriteExcel( FilePath = ExpandPath( "./Sheet1.xls" ), Sheets = objSheet, HeaderCSS = "border-bottom: 2px solid dark_green ;", RowCSS = "border-bottom: 1px dotted gray ;" ) />
CFINVOKE - refreshWSDL
I was implementing a web service the other day, it all went ok until I had to add another parameter on the web service function.
Suddenly my test template doesn’t work, I suspected the problem has to do with the stubs not being refreshed, so I refreshed it using CF admin interface, but it didn’t solve it.
I asked my workmate, he pointed me to a parameter in CFINVOKE method that I never heard before: refreshWSDL (my Eclipse didn’t suggest me this parameter neither did Dreamweaver 8)… Setting this parameter to true solves the problem.
1st CFUG
Tonight was my first time coming to CFUG, well it’s now called Adobe Platform Users Group (APUG) as NSW CFUG and the Flash User Group merged together. Managed to get one workmate to join, he’s a CF enthusiast and has been to these meetings before. But rather unfortunatelly the other 6 weren’t interested, how can I get these people interested in being involved in CF community I wonder…
Also managed to caught up with 2 mates from the old workplace which is good.
Geoff from Daemon gave a presentation on open source community, he gave tips on what can developers do to help out the community (things like: submitting bug reports, feature requests, contributing financially etc2). He also shared a bit his experience with FarCry of which he is the benevolent dictator.
He also explained some of the open source licences, he brought into our attention the difference between GPL and LGPL and gave an example of the current controversy on ExtJS community caused by moving the library from LGPL to GPL (a controversy that I wasn’t aware of, wonder why I haven’t seen it blogged on CF or Flex blogs).
It was an informative session, I am glad that I came.
CFDBINFO rocks
If you aren’t using ORM, do you find yourself hand coding insert update statements on your CFC (or CFM?). Sure you can script a table with SQL Server and use it for your code, but you would still need to hand code the cfqueryparams.
Last week I wrote a few utilities that helped me with my work. One of them is an Insert/update SQL template generator, it produces SQL statements that can be used directly on database (cut and paste the statement to query analizer) or another option is to produce a cfquery statement with its respective cfqueryparams (cut and paste the statement to a CFM or CFC).
Another utility: pick a table name, upload a CSV with values to be inserted/updated to that table. Run the utility, you can choose to have it run immidiatelly on database or have it to produce insert/update SQL statements.
The ability to introspect table and get all the information (meta data?) of the table is really fascinating! This is especially useful for me as at RECRUITadvantage, we have a strict protocol of database operations (SQL scripts have to be approved by the DBAs).
To wrap up, if you are not using ORM, play around with CFDBINFO, maybe it can help you with automating some of your database work.
ColdFusion Exam Prep
Ha! Just realized today that Ben actually has this: Ben Forta’s Exam Page which is exactly what I wanted to build using ColdBox (and Transfer). I’d still be interested in building the application though as it’s a perfect side project for me to learn the frameworks.
Oh I just failed the test, I scored 57% ![]()
Update: Link fixed, thanks Charlie!
Sporadic Learning
Yep, that’s my method of learning, basically I just learn whatever it is that comes to my fancy. A while ago it was Model-Glue, a week ago it was Flex, lo and behold, I am now captivated by ColdBox!
I guess this also can be considered as my weaknesses, being unable to be interested in one thing for long if I am not forced too. With learning these frameworks and Flex, there’s no one really asking me to do it, so there’s no pressure and I am completely free to choose whether I want to continue learning the technology or not. I need to prioritize better, I need to think through which of “the oh so many wonderful things to learn”, that can be reasonably beneficial to my career and to whoever that hires me (or will employ me).
I guess my sporadic learning at the moment is bounded by Adobe related things and web development in general, I haven’t stepped in to Ruby on Rails yet, although each day I am getting more and more compelled to at least give it a try.
CFQuery LIKE on NULL values
I’ve got this query of query:
SELECT * FROM qSectionArticles WHERE displays LIKE '%publications%'
This code was returning a CF error:
The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code. Null Pointers are another name for undefined values. .... Stack Trace java.lang.NullPointerException at org.apache.oro.text.regex.Perl5Matcher.matches(Unknown Source) at coldfusion.sql.imq.rttExprCondLike.evaluate(rttExprCond.java:543) at coldfusion.sql.imq.rttExprCondTest.evaluate(rttExprCond.java:273) at coldfusion.sql.imq.rttSelectExprSpec.evaluateWhere(rttSelectExprSpec.java:245) at coldfusion.sql.imq.rttSelectExprSpec.evaluate(rttSelectExprSpec.java:184) at coldfusion.sql.imq.rttSelectStmt.evaluate(rttSelectStmt.java:61) at coldfusion.sql.imq.jdbcStatement.fetchResult(jdbcStatement.java:539) at coldfusion.sql.imq.jdbcStatement.execute(jdbcStatement.java:131) at coldfusion.sql.imq.jdbcPreparedStatement.execute(jdbcPreparedStatement.java:96) at coldfusion.sql.Executive.executeQuery(Executive.java:1202) at coldfusion.sql.SqlImpl.execute(SqlImpl.java:329) at coldfusion.tagext.sql.QueryTag.executeQuery(QueryTag.java:831) at coldfusion.tagext.sql.QueryTag.doEndTag(QueryTag.java:521) ...
It turns out the problem was that I the column that I am querying for (displays column) has a NULL value assigned to it, luckily there are only 5 or so entries in this table, so I can just quickly fill them with values and change the field to not allowing NULL as well as giving it a default value (the database is SQL Server 2000 by the way)
Sydney CFCAMP
Just came back from Sydney CFCAMP, needless to say I was blown away by the quality of the presentations and the wealth of information and knowledge given.
In a nutshell:
- Adam Lehman started off with presentation of Coldfusion 8 features. What’s most helpful from his presentation was the big picture of the range of solutions that Adobe provides and where Coldfusion sits within them (relating to Flex, .NET etc2)
- Robin from Rocketboots gave a presentation on CFInterface, it’s quite refreshing to be reminded of this OO feature as at my workplace we aren’t doing OO with Coldfusion.
- At least this got us thinking more about the benefit of moving to OO.
- Coldfusion and Flex integration by Nick Watson. Don’t remember much about this preso, mental note that I took is, there is Life Cycle (whatever it is) server that comes with Coldfusion server and we can utilize that to I guess provide connectivity between CF and Flex (publish/subscribe pattern?)
- Geoff from Daemon gave a presentation on FarCry. He demonstrated how easy it is to extend FarCry framework and build solutions on top of it. And he did make it look so easy. We were wow-ed by the quality of the FarCry dashboard, felt a bit shame that some the features we have in our own framework don’t look as complete nor easy to use like the ones in FarCry. We’re compelled to give FarCry ago (one day).
- Andrew Spaulding talked about Coldfusion and Microsoft Exchange integration.
- Peter Bell talked about Code Generation. An inspiring presentation, I have done a study on Software Production Line and Domain Specific Language so the what he talked about is not something new to me. One thing that I got out of the presentation is DSL and Framework are two ways of achieving the same thing (if I am not wrong), so if you already using one or the other then you are good, you are not wasting your development time. With someone at work keep on preaching about Rails, I really like to dive into this whole code generation thing. I think the first step for me is to actually adopt a framework and play with it (like I halfway did with Model-Glue)
- Adam came up again and talked about features of CF8 like CFImage, CFDocument, Ajax, lots of cool things that I wonder whether I will ever have the priviledge to try.
I guess at the end of the day, I got a confidence boost to choose to become an Adobe specialist as a viable career path. When talking about Adobe, I feel like getting the goodness of the community, it feels like being a part of an open source community (let’s not dwell into the debate whether or not Adobe is an open source camp), and yet at the same time I feel the security of being a part of a well established commercial entity (that isn’t evil).
