Entries for month: July 2008
Multi-Step form in Model-Glue with Services
While I don't make any claims at being a model-glue expert, I did come up with a way to run my multi-step forms in model-glue. I basically use a single 'event' entry point that has several named results, and the single entry point controller runs 'makeEventBean()' against my form bean (kept in session), and then passes the bean to the service and asks 'what is my next step?' The next named step gets fired off to the named result, and the user see's the appropriate screen in the multi-step process. I am using Transfer ORM, so inside the service you will see some use of that code. Also, I am not going to paste the display files here, this is just really to blog about the gist of my methods to handle a multi-step form. There are quite a few little code chunks here, so without further ado...
CfEclipse Beta and Eclipse 3.4 issues and resolutions
I am rocking the latest CfEclipse Beta and Eclipse 3.4. Impressions? Fast, I love the updated SVN dialog boxes, and everything feels nice and stable. Only problems were Tag-Insight for CfEclipse and missing line numbers. CJ from IRc (thanks bud!) pointed me to the fixes, so I figured I would share.
To fix the missing tag-insight: Right click your project, and select 'Add Remove CFE Nature' (no clue what it is or does, but it fixed me right up)
To fix missing line numbers: in your workspace, find file .metadata\.plugins\org.eclipse.core.runtime\.settings\org.cfeclipse.cfml.prefs and add a line with this text: lineNumberRuler=true
Have a great weekend all!
Setting up a dev environment
This may not be applicable to everyone, but I like my work environment to be fairly portable and simple to work with, so in no particular order, let me share with you how I setup my Eclipse / Coldfusion development environment on Windows.
5 lines of a custom tag that save me tons of headache
Often times when I am writing ajax or model-glue apps, something will go wrong and its difficult to see the values that are complaining. Sure, you could pass things forward to the view, catch/try, maybe set your controller to allow output and dump it from there, but this little custom tag seems to do the trick most of the time for me.
<cfset dumpMe = attributes.var />
<cfsavecontent variable="debug">
<cfdump var="#dumpMe#">
</cfsavecontent>
<cffile action="write" file="#attributes.file#" output="#debug#">
its called 'fileDump.cfm' in my custom tags folder, and you use it just like you would think:
<cf_filedump var="#varToDump#" file="c:\debug.html" />
Now I will get a nice file I can open up regardless of the final rendered output of my page / event, and see what the heck is going on. You can dump the entire event, or the 'this' or 'variables' scope as well, and get the whole ball of wax in a nice file that you can dig through at your leisure!
Classic Programming Mistakes
I saw a link posted this morning to Steve McConnell's blog about common programming mistakes, and many of them were very applicable to a project I am working on currently. Programmers being typically helpful people, and wanting to please their customers, I think we often get ourselves into trouble trying to stand up to un-realistic goals and ideals, simply because we dont want to disappoint anyone. This list really puts into words some of the no-no's to remember when you are gearing up for a large coding project. Just because the customer wants it in X timeframe does not always mean that it can be done in that time. I think most of my customers would have rather had a realistic estimate than a 'can do' on the front end, and a pushed deadline near the end!
So check it out: www.stevemcconnel.com - Classic Mistakes Enumerated (from 1996 no less!)
Let me know what you think, I believe he hit the idea's square on the head.
Writing code to write code (metacode, love it)
I got detoured off my large project to do a quick financial report, something that pulls in tons of values from a few other reports, has some manually added data, and of course has to match some funky bank-format Excel spreadsheet (I just LOVE those). So, I have a nice list of about 50 fields that have to be populated with data, all according to varying formulas. Well, I hate creating getters / setters and form code, so I whipped something together to loop through the list of field names and generate em both for me. For anyone who has never done anything like this, check out some samples.
This code generates my get/set pairs for a simple form bean:
<cfloop list="#list#" index="i">
<br />
&lt;cffunction name="set#trim(i)#" access="public" returntype="void"&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;cfargument name="#trim(i)#" type="numeric" required="yes" /&gt;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;cfset variables.values.#trim(i)# = arguments.#trim(i)# /&gt;<br />
&lt;/cffunction&gt;<br />
<br />
&lt;cffunction name="get#trim(i)#" access="public" returntype="any"&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;cfreturn variables.values.#trim(i)# /&gt;<br />
&lt;/cffunction&gt;<br />
<br />
</cfloop></code>
</cfoutput>
and this code generates my simple form based on thise field names (tweaking will have to be done of course, but this gets it together very quickly):
<cfloop list="#list#" index="i">
<br />
&lt;label&gt;#trim(i)#<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;span class="small"&gt;Set #trim(i)#&lt;/span&gt;<br />
&lt;/label&gt;<br />
&lt;input type="text" name="#trim(i)#" id="#trim(i)#" value="##formBean.get#trim(i)#()##" &lt;cfif len(formBean.get#trim(i)#()) gt 0&gt;disabled = "disabled"&lt;/cfif&gt; /&gt;<br />
<br />
</cfloop>
</code></cfoutput>
Ack, where is all the content!
I have migrated to a virtual server (yah for full control over the server!) I was having a heck of a time converting all my data from MySQL into MS SQL, then I had plugin issues with Mango after copying my web root via FTP onto the new server, so I nuked it! This is a clean install of Mango on MS SQL. I will try and get my data imported from the old database, but until then the world will have to suffer the (minimal) loss of my prior blog posts.