Entries for Tag: 'coldfusion'
Quote from:
the FAQ from Google's new programming language Go:
Do not communicate by sharing memory. Instead, share memory by communicating.
This is a very succinct and eloquent way of saying something that I have been stressing for years when talking to web developers. OO principles teach this by way of saying that your apps should be loosely coupled, but there are too many people that do not get what this means. I usually try to describe it as "Only let this object or method work with what it is given". Never act on data that you are not explicitly given. You cannot be sure it will always be there, and you cannot be guaranteed that it will be in the proper form for you to work with.
Posted on Wed. November 11, 2009 by Ryan Guill
#
So let me set the scene. I have been trying to push adb.com to production for a few weeks now, but something was always coming up so I didn't have the time to get it finished. I had the source code in subversion at one point, but during a backup and reinstall of my development system somewhere along the way, I had unhooked it. But I still had all of the .svn folders in my code. That's where the fun starts.
continue reading...
Posted on Mon. August 18, 2008 by Ryan Guill
#
I am really glad you could join me for taking my new website for a spin. I am going to break it in slowly, but kick the tires for me and let me know if you see anything out of place, mis-spelt or just plain broken. But overall just let me know what you think!
Posted on Sun. August 17, 2008 by Ryan Guill
#
Lately we have been writing a lot of webservices to help integrate with some other language systems across the company and we ran into an issue that I know others have ran into, but haven't seen anyone else realize exactly what the problem is.
I was returning a complex data type from the webservice ( long story, but we wanted to make sure that the individual items in the result showed up in the wsdl) so I had a cfcomponent with properties of each of the items we were going to return, and then we were creating an object out of the component and returning it.
Quick note here, I oftentimes will wrap the contents of my cfcomponent tags in cfsilent tags to help suppress whitespace. Dont do this with the components for this purpose, the webservice doesn't like it much.
Back to the issue at hand, I kept getting the error:
faultString: org.xml.sax.SAXParseException: Premature end of file.
I only got this when invoking it as a webservice, as a regular component invoke it worked fine.
I finally realized, that after creating the object in the method to be returned, you have to set all of the different variables to their default values, so you make sure you set all of the variables in the object or they wont be defined. You have to do this, even if you put a default="" on your cfproperty definitions.
So if you ever run into this, make sure you are initializing all of your variables in the object before returning it.
If I haven't been clear about any of this, let me know, but send me an email to ryanguill [at] gmail [dot] com, my mail server on my server still isn't working so I may not see your comments.
Posted on Wed. December 13, 2006 by Ryan Guill
#
I ran across something today that I just want to get into google in case someone cant figure it out.
What would you expect the output from the following code would be?
Think about it. 0 is obviously not a valid date. My first instinct is that it would return 0, and if not, that it would throw an error about an invalid date. Nope.
It returns: 1899-12-30. Two days before 1900-01-01. Any ideas why?
My guess (and while it is slightly educated it could be very very wrong) is that it has something to do with epoch. and because of wierdness with leap years around the turn of the century, they backed up epoch a couple of days to make date functions easier.
Either way, dont expect the above to throw an error, expect it to give you something very very strange...
Posted on Tue. September 05, 2006 by Ryan Guill
#
Just a quick note here on a dateDiff() gotcha I came across today. I had two coldfusion timestamp objects, one that was being pulled out of a date field of a database so it comes out as midnight on that date, and one generated using now(). I was wanting to get the difference in days between the two dates. My dates looked like so:
Target date: {ts '2006-06-07 00:00:00'}
Todays Date: {ts '2006-06-06 00:00:01'}
I was calling my date diff like so:
What I was noticing was that all of my diffs were coming back a day less than I expected if the target date was in the future and a day more if it was in the past. The reason for this was that even though I was using the datepart "d" for days, it was counting a day as a full 24 hours, not looking at just the date itself. It was also evaluating the time part of the object. Just having one second less than a full 24 hours was subtracting a day (if the target date was in the future). So to get around the issue, I had to make sure that both of the days were only evaluated as date objects not timestamps, which effectivly makes both at midnight for that date. So I whipped up a quick function that I could call to do that for me:
Since coldfusion doesnt have a date() function, you could rename this function to that if you want. Im sure there is also something at cflib that will do the same thing but it was just as fast for me to write one that did what I needed.
Hopefully this will help someone else in the future.
Posted on Tue. June 06, 2006 by Ryan Guill
#
For those of you interested, I have set up a quick and dirty create script for MySQL 5 for Ray's Canvas Wiki. You should see the download link on this entry. I dont know enough about the wiki be certain that there is nothing wrong with it, but at first blush it seems to be working fine. Let me know if you have any trouble with it.
Posted on Wed. April 05, 2006 by Ryan Guill
#
They say you learn something new every day. Or maybe its that you should try to learn something new every day. Either way, its true for me!
I was looking at some sample code in reactor today and noticed that a variable was being set in the applicaiton scope. I wanted to make sure it was reloaded, so I was going to try to go change the application name so i knew that it would happen. But I looked and looked and couldnt find the cfapplication tag....
I was under the impression that the application and session scopes required the cfapplication tag (or at least an application.cfc) but there was none and it was working...
come to find out, this isnt required at all. It is going into some sort of non-named application scope and it works just fine.
Now it is not something that I recomend by any means, it could cause some very subtle and hard to track down bugs, but it is possible.
Did this change from a previous version? I could have sworn it was like this in the past at least...
To prove it you can stick this in a new folder with no parrent application.cfm file...
Should work just fine (at least on cf 7.0.1 with mystic beta...)
Posted on Mon. March 13, 2006 by Ryan Guill
#
Not sure where I saw this, I think it must have been
MXNA but just wanted to bump it up in case some of you may have missed it.
In CF (comes standard) there is a bat file that you can use to create your cfcharts with a GUI editor. LOTS of new cfchart types are in there and it helps you get things just right. I havent checked it out in practice yet, but looking through its very very cool.
You can get to it at {cfusionmx}/charting/webcharts.bat.
More info here:
http://www.orbwave.com/cfjboss/2005/12/customizing-your-cfchart-results.html
Posted on Wed. December 21, 2005 by Ryan Guill
#
When you are passing someone on the street and you ask for the time, what do they tell you? Do they say oh, it is 6:47 PM, or do they say quarter till seven? Well thats called fuzzy time and some kde users may recognize it. Well recently I wanted to put something like that in one of my apps, so here is a pretty basic version of a udf called fuzzyTimeFormat(). You can pass in a timestamp or not, if not it will use the current timestamp.
continue reading...
Posted on Wed. December 14, 2005 by Ryan Guill
#
I had a request today to be able to ping a server or website using coldfusion and extract the importaint information. So I whipped up a small function that allows you to do just that. This function returns a struct full of information, you can decide what you need out of it. It *could* return a little more information, but that is left as an exercise to the reader.
Also, I have done the same thing for tracert, and the windows systeminfo command (if you dont know what that is, go to a command line and type systeminfo), but I haven't packaged them up into functions yet. Stay tuned for those.
This code has been tested on cfmx 7.0.0, and win2k3 server. Im not sure if this would work on linux or osx or any other system because im not sure how their ping commands work. I have a feeling this wouldn't work on those systems.
So without further ado, here is ping():
<cffunction name="ping" access="public" returntype="struct" output="false">
<cfargument name="target_name" type="string" required="false" default="127.0.0.1" />
<cfargument name="options" type="string" required="False" default="" />
<cfset VAR out = structNew() />
<cfset VAR execRet = "" />
<cfset VAR i = 0 />
<cftry>
<cfexecute name="ping.exe" timeout="60" arguments="#arguments.target_name# #arguments.options#" variable="execRet" />
<cfcatch>
<cfthrow message="ping process timed out" />
</cfcatch>
</cftry>
<cfset out.target_name = arguments.target_name />
<cfset out.options = arguments.options />
<cfset out.execResults = execRet />
<cfset out.arExecResults = listToArray(execRet, createObject("java", "java.lang.System").getProperty("line.separator"))/>
<cfset out.summary = out.arExecResults[arrayLen(out.arExecResults)] />
<cfset out.arSummary = listToArray(out.summary) />
<cfset out.summaryInfo = structNew() />
<cfloop from="1" to="#arrayLen(out.arSummary)#" index="i">
<cfset out.summaryInfo[trim(listFirst(out.arSummary[i],"="))] = trim(listLast(out.arSummary[i],"=")) />
</cfloop>
<cfreturn out />
</cffunction>
If you do not pass in the target_name (which can be an ip address or website or computer name) it will use 127.0.0.1. It also has the optional 'options' argument. To see it in action, stick the function on a page and run:
<cfdump var="#ping('www.ryanguill.com','-n 10')#" />
Posted on Wed. December 07, 2005 by Ryan Guill
#
Almost a year ago now I posted
a tip on cfcase about how you could make cfcase self terminating like so:
<cfswitch expression="#expression#">
<cfcase value="foo1"/>
<cfdefaultcase>
do something...
</cfdefaultcase>
</cfswitch>
Its useful for checking to see if a value passed is one out of a group of expected values. But reading through the new
cfQuickDocs I noticed that there is another attribute to cfcase, a dilimiter. Maybe this is common knowledge to others, but I dont guess I come across the need for this very often so I never went looking for it. But either way, Say you wanted to validate that someone passed in the either a Y, a N, or a U into a function you created. If its not one of those values you throw an error. You could then do it like this:
<cfswitch expression="#expression#">
<cfcase value="Y;N:U" delimiters=";" />
<cfdefaultcase>
<cfthrow message="No Sir...." />
</cfdefaultcase>
</cfswitch>
simple eh?
Posted on Fri. November 11, 2005 by Ryan Guill
#
I just wanted to bring this up because I believe a lot of people missed it when Steve blogged it the other day.
His awesome guide, the ACME guide, now has a downloadable ISO available with everything you need to get started. I am hosting it for him here at ryanguill.com.
For more information, see
Steve Collins Acid Website, and to download it, check out
my docs page.
Posted on Tue. September 27, 2005 by Ryan Guill
#
I posted this to the COAL mailing list last night:
I had an epiphany of sorts today after a conversation on cf-talk. Its something that I have known for a long time in the back of my mind,
but never fully realized it. First a little background.
You cannot duplicate or copy components. Components (objects) are passed by reference, not by value. And the duplicate() method doesn't
work on objects. If you aren't with me, consider the following code.
<cfset variables.x = createObject("component","myObject").init() />
<cfset variables.y = variables.x />
If objects were passed by value, variables.y would hold its own copy of the object. But since objects are passed by reference, variables.y
and variables.x hold the exact same object. So If we make a change in variables.y, the change was also made in variables.x.
So why is this a problem? Because in COAL, I implemented part of the service locator pattern that is the caching agent. Which makes sense
in the service locator pattern, because the pattern is working with _services_, not objects. Services are stateless. You can create
objects out of them, but they should have no instance data. They are also singletons, and only one copy should exist per application. So
if the code was to request a service that has already been created, it should give them the exact same copy of the service, not a new one.
But this doesn't work with the objects that COAL is supposed to create. So basically the caching agent in COAL is useless, and should
not be used.
I haven't run into any problems with COAL yet though, because I always turn caching off anyway. But I am sure if I was using the caching, it
would have caused problems by now.
So, sorry for that long explanation, but this is whats going to happen. The service locator pattern is still great for COAL in the way that you can request just the object name (that you have given it in the config xml document) and get it to know where the component is stored and create the object for you. So we are just going to take the caching agent out of the "framework" code. I am going to leave the cache attribute in the coal.cfc init() for now for backwards
compatibility, but it will basically be disabled, no matter what you give it there will be no cache. So the implementations you already have wont break, just that functionality (which is and should be transparent at this point anyway) will just cease to exist. You should go ahead and take that attribute out if you are using it now
because it will be taken out completely in future versions.
Sorry about this dumb mistake guys. But it should all be fixed pretty easily by this weekend. Any comments or suggestions on the matter are
welcome.
Posted on Tue. September 27, 2005 by Ryan Guill
#
Quick post, but everyone that is using the CF7 Event gateway with XMPP should be interested in this
http://www.macromedia.com/go/b39b42b5
Make sure you update your jar files to keep things running smoothly.
Posted on Fri. September 16, 2005 by Ryan Guill
#
On one of the lists today someone asked about how to store a udf on a cfm page in a different scope, such as the application scope.
Something that not many developers realise is that when you create a function in a cfm page (actually for a cfc as well) it is stored in the variables scope for that page. So, if in test.cfm you create the following function:
<cffunction name="foo" access="public" returntype="boolean" output="false">
<cfreturn True />
</cffunction>
Then you can of course call the function using the following syntax:
<cfset variables.result = foo() />
but you can also access the function by using:
<cfset variables.result = variables.foo() />
because the foo() function is stored in the variables scope. now what if you wanted to access it using application.foo() ? Well you can not do this:
<cfset application.foo = foo />
That code will bomb and tell you that foo isnt defined. I am not exactly sure why this is, but you can do this:
<cfset application.foo = variables.foo />
and then you can call the function from then on using application.foo().
To see this in action, create a udf on a .cfm page and then dump the variables scope like so:
<cfdump var="#variables#" />
And to see it in action in a cfc, put the following method in one of your cfc's that has some other methods in it:
<cffunction name="dumpVariables" access="public" returntype="struct" output="false">
<cfreturn variables />
</cffunction>
and then call the method from a .cfm page and dump the results. you will see all of the methods in the cfc. This is also why if I am ever storing variables inside of a component, I use variables.properties structure instead of using the variables scope directly.
Posted on Tue. September 13, 2005 by Ryan Guill
#
This morning I came into work and started working on an application I built using cfgrid. It was displaying everything just fine on my screen, but when a coworker tried to hit it, the query data was not showing up. A dump proved that the query did exist and have records in it on his machine, cfgrid just wasnt showing the data. I went and checked, I was using firefox with flash player 8. I opened up ie that was still using flash player 7, and it didnt work. Updated it to 8, and it started working without any change to the code.
Has anyone else noticed this behavior and is there a workaround? We really need this to work on 7 for the time being...
Guess that goes to show you that you can't always assume that it is your code screwing up!
Update: It was my code actually...
I had the same name for my grid as I did for the form itself. But it wasn't throwing a compile error. And the real strange thing was that flash 8 was working fine even with the same names, but flash 7 wasn't. Very strange indeed.
Posted on Tue. September 06, 2005 by Ryan Guill
#
Today we will start trying to work with the brand spanking new Coldfusion 7 Report Builder. In thinking about this I realized that there hasn't been much discussion (if any at all!) about the report builder on any of the lists or blogs that I frequent. Is anyone out there using the report builder? Does anyone know if you can create these reports and have them generated on the fly from coldfusion code? Does anyone know of any quirks or gotchas? Im sure if no one answers I will have some things to talk about with it soon, so stay tuned!
Posted on Wed. August 31, 2005 by Ryan Guill
#
I am looking for a directory or library of webservices. Google didnt turn up much so I was wondering what some of the common services that you guys use are. I am particularly interested in weather webservices (specifically that take a zip code and return current conditions and at least a three day forcast, but im really not all that picky ;))
Has anyone else had trouble with finding webservices?
Posted on Fri. August 26, 2005 by Ryan Guill
#
or a better title may have been: Event Gateways, like an american kid in a japanese candy store.
Well I started messing around with the event gateways today. With all the hype (and counter-hype) surrounding gTalk and all, I thought it was finally time to have try my hand at it.
First epiphany (dont care if thats how you spell it or not ;P): Event gateways are services, not objects!! I am going to have to drill this into my thick head im sure. I was assuming since I was creating an "instance" of the gateway in the administrator, that it was a persistant object. But thats not true, it recreates the component object every time a message is sent (and I can only assume that it is destroyed as soon as it is done doing whatever you have had it do)
Next step, figure out why my session scope isnt accessible. application scope is though... and since its not persistant, variables scope in a component wont work either....
Posted on Thu. August 25, 2005 by Ryan Guill
#
Two things of interest to anyone who is going to be using cfforms here. I know I am definately going to be looking for this post again some time.
You can not use any of the following actionscript commands in flashforms:
import
new
delete
createChild
loadmovie
duplicateMovieClip
AttachMovie
registerclass
createTextField
__proto__
(the capitalization is theirs from the error that is thrown)
one thing of notice, and I cant prove this again at the moment, but I am almost certain that I was able to do an import the other day.... more on that later.
Now for the second thing of interest. You cant use any of those words in a tooltip in a cfform as well... Now this sucks. So I cant put
, at least I cant without cf complaining.
So this begs the question, is this an oversight or overzealous code checker or can we use actionscript inside of the tooltips??
UPDATE:
new actionscript restrictions in 7.0.1
* createchild
* Createchildatdepth
* Createchildren
* Createclasschildatdepth
* Createclassobject
* Createemptyobject
* createobject
* httpservice
* remoteobject
* Uiobjectdescriptor
* webservice
Posted on Tue. August 09, 2005 by Ryan Guill
#
Update:
I found a workaround, although I am still open to other and better ideas.
I have a panel that is being set to visible=false if a radio button is not selected. It works something like this:
<cfformgroup type="panel" visible="{(MyRadioButtonName.selectedData == 'MyRadioButtonValue')?true:false}" ...>
So when that specific value or button is not selected, visible is set to false and it doesn't show up, but the space that it would take up were it visible is still there just blank. So what I have done is added the height attribute, like this:
<cfformgroup type="panel" visible="{(MyRadioButtonName.selectedData == 'MyRadioButtonValue')?true:false}" height="{(MyRadioButtonName.selectedData == 'MyRadioButtonValue')?150:0}">
So this will set the height to 0 if that radio button is not selected. works for me at the moment, although I still realize its not the best possible solution.
Posted on Tue. July 26, 2005 by Ryan Guill
#
Another question I have about flash forms is,
is there a way, similar to setting a panel visible="false", that you can make it not show up, and not take up that space? Where if its not visible, there is no hole, but if it is made visible that everything will slide down?
Update: See the
next blog post for my temporary solution.
Posted on Tue. July 26, 2005 by Ryan Guill
#
We'll I have gotten some new experience this week with the new cf 7 flash forms. They are entirely awesome, but unfortunately, they gave me an inch, and im trying to take a couple thousand miles...
I am finding that the applicable documentation is sparse at best. We are trying to do some pretty wild action script stuff, which I am almost certain is possible, but without being able to see some documentation or even examples about how something like this might be achieved, its sort of impossible. My cfwack books are useless, and even cfform.com doesn't have much on the subjects. So I am here to appeal to you guys, can you help? Here are a few of my questions:
Can someone give me a applicable documenation resource for the properties of flash form controls? I need to know when I can use .text, .length, .selectedData, etc.
Can anyone tell me why .text property of a
Posted on Tue. July 26, 2005 by Ryan Guill
#
Well, last week was just not my week for installing servers. I started out the beginning of the week trying to get cfmx 7 installed as multi-server or j2ee server on my development laptop, so I could then install flex on top of it and be able to request .mxml files the same way I request .cfm files. (if it is not true that you have to install things that way in order to do that, please let me know). But no dice. cfmx 7 never would install correctly, flex most certainly not. I finally got everything back to normal by installing cfmx 7 back to the laptop as a normal server option (the first option in the list). Then we tried to update our dedicated production server to 7 as well. I tried over 14 times in two days, 7 of those after we completely reinstalled the os, every combination of things we could think of. Still no dice. I could not even get the normal version installed there. I was getting all sorts of errors from just the webservice connectors not being installed, jrun just flat out not working, The cf server would install but not start, the odbc services were not even being installed, I was getting error messages saying something about a licenseservice and you name it.
I suppose I will be viligent and try again, I know how much the new features of 7 are worth it. But if any of these troubles ring a bell for any of you guys, please let me know if you have any suggestions.
Posted on Mon. June 06, 2005 by Ryan Guill
#
I may be going crazy here, but I am almost certain in cfmx 6.1 you could NOT nest cfoutput tags correct? Well it looks like you can in cfmx 7. I was looking at some code that wasn't throwing an error today and noticed I had accidentaly nested them. I refreshed a couple of times because I knew it should be throwing an error but it never did. If I took out one of the closing tags it would throw an error, so I knew both sets were working. Was this something that changed in cfmx 7 or has it always been this way?
Posted on Wed. June 01, 2005 by Ryan Guill
#
Of course we are now all going to be using adobe coldfusion (man that just doesn't sound right), so will they have to change it to the adobe xml news aggregator? guess so.
I don't know what to think about the whole macromedia being bought into oblivion, except to think that I feel like a name, a brand, a company that I have depended on daily for years has just left me in the cold. But i'll make it. I would just feel a whole lot better if adobe would make their intentions for ColdFusion known. Are they going to continue its development? keep it limping along for a while? ride the cfmx 7 wave as long as it lasts and then say, well that was fun? I can see it going either way, and so far the only thing I have seen is opinions from people who obviously don't know what they are talking about (ie, coldfusion was dead anyway, etc). It's going to be a long road, but as with everything else I guess, the journey is half the fun!
Posted on Mon. April 18, 2005 by Ryan Guill
#
Well, I just upgraded my blog to the new version 3.6.3. Went well as far as I can tell, even though I had done several mods that I had to redo. This post will really be the final test to see if I got everything.
Really looking forward to the future posts for my trips out of town.
Posted on Fri. April 08, 2005 by Ryan Guill
#
Anyone that has ever done a coldfusion hotfix will find this information from Talking Tree useful.
Posted on Tue. March 29, 2005 by Ryan Guill
#
Boyzoid reports on using Jabber to connect Coldfusion to Yahoo!, AIM or MSN. Defintately a good bookmark. Can't wait to get started with event gateways.
Posted on Tue. March 29, 2005 by Ryan Guill
#
Ever wanted to recommend products to your customers on your website simliar to what amazon does? Might want to check out
this link from Blog in Black.
Posted on Tue. March 29, 2005 by Ryan Guill
#
This blog post/article is dedicated to rudy on
sitepoint.com. Rudy is a sql guru and says he is a coldfusion novice. Yet he does have a great handle on computer languages and how they work. He has mentioned several times that he doesn't see the need for coldfusion components, mostly because he doesn't understand them. And he has yet to have anyone explain to them in a way that doesnt use the words "object", "method", or "instantiation". So thats what I am going to do with this article.
continue reading...
Posted on Fri. February 25, 2005 by Ryan Guill
#
Trying to get your employer or even clients to buy into the new cfmx 7?
this article on communitymx can help. its a great overview and really explains a lot. I hope to be able to upgrade very soon.
Posted on Wed. February 23, 2005 by Ryan Guill
#
I had to do some work with cfdirectory today, and I found that the documentation is horrible. So just so you know, if you need to do a cfdirectory action="create", all you need is action="create" and directory="", and you must use ExpandPath() inside it. Those are the only two attributes you need. When it comes to deleteing a directory, I just found another reason to switch to cfmx 7, the recurse="true" attribute. Im just not going to use cfdirectory action="delete" on 6.1, its just not worth it.
Funny thing though is that if you go to the 6.1 livedocs for coldfusion, and look through the comments, one of the macromedia guys let it slip that it was coming.
Posted on Fri. February 18, 2005 by Ryan Guill
#
The converstation seems to come up regularly. Why is one programming language better than another? Historically programmers are emotionally connected to their programming languages (you spend that much time with something/someone youre going to start to get attachted) and so the discussions often become heated.
But by far, one of the strongest cases for coldfusion as a web language for me is Rapid Application Developement. You just cant get something out any faster that is as robust as a CF application. Why am I mentioning this now? I just created a standard features Forum in cf in a little less than 6 hours. Maybe if you really knew your language you could do it faster than that in something else, but I would really be surprised. I know I couldn't in anything else.
Posted on Wed. January 05, 2005 by Ryan Guill
#
From the Coldfusion MX 6.1 Documentation:
"Using component.cfc
All CFCs automatically extend the ColdFusion WEB-INF\cftags\component.cfc component. (WEB-INF is in the cf_root/wwwroot directory on ColdFusion configured with an embedded J2EE server. It is in the cf_root directory when you deploy ColdFusion on a J2EE server.) This CFC is distributed as a zero-length file. You can use it for any core methods or properties that you want all CFCs in your ColdFusion application server instance to inherit. "
Actually, I could not find the component.cfc at all, so all you have to do is create it in the right directory. This is a great place to put methods you will use in all of your components, or in other words, a great place to use base.cfc methods!
UPDATE:
After talking with Sean Corfield, Ben (im sorry, i have forgotten your last name) and Scott Barnes last night, it seems that they have some reservations and concerns about using the component.cfc. I will try this and see what ramifications come of it, but they are probably right. They described another way to do things, besides extending the base.cfc through the use of extend="" to use the base.cfc methods. I am going to try it and I will post the steps to do so and how it went here later.
Posted on Tue. December 14, 2004 by Ryan Guill
#
Oftentimes in my code I employ a switch to validate input, such as for an argument passed into a method. In many of theses cases I only want to do something if the input is not an expected value, or in a group of expected values. Until now, I just had empty
blocks like so:
<cfswitch expression="#Variables.Expression#">
<cfcase value="expectedvalue1">
</cfcase>
<cfcase value="expectedvalue2">
</cfcase>
<cfdefaultcase>
Expression is not one of the expected values...
</cfdefaultcase>
</cfswitch>
In the code above it isn't such a big deal, but you can see how quickly your code can become bloated with empty blocks if you had several values to test for. Well today I decided to try something that wasn't in the documentation to see if it would work. When you have an empty block, you can make it a self terminating tag, making your code much easier to read like so:
<cfswitch expression="#Variables.Expression#">
<cfcase value="expectedvalue1" />
<cfcase value="expectedvalue2" />
<cfdefaultcase>
Expression is not one of the expected values...
</cfdefaultcase>
</cfswitch>
this makes things much neater and easier to read, not to mention faster to type out. There are several tags in cf that you can do this with, but some of them require specific end tags, so be careful when trying them.
Posted on Mon. December 13, 2004 by Ryan Guill
#
if you are working on a cf application and you need to update it, and you dont want anyone to try to be working with the application in the mean time, you can use this little bit of code to help.
put the following code in your main application.cfm file:
<cfparam name="Application.LockApplication" default="0" />
<cfif IsDefined("url.LockApplication") AND IsDefined("url.Password")>
<cfif url.password EQ "password">
<cfif Application.LockApplication>
<cfset Application.LockApplication = 0 />
<cfelse>
<cfset Application.LockApplication = 1 />
</cfif>
</cfif>
</cfif>
<cfif Application.LockApplication>
<p>The Application has been locked for maintenance. Please see your administrator.</p>
<cfabort />
</cfif>
of course you will want to chang password to something more secure, and there are other things you can do to make it a little more secure, but this quick and dirty script will get the job done. just use [anyurl]?lockapplication&password=password to lock the application, and use the same to unlock it.
easy.
Posted on Sun. December 12, 2004 by Ryan Guill
#