At work, we had some old display code that was supposed to prevent users from submitting the same form twice. In the form's submit event, there was a window scoped boolean being set. If validation errors needed to be displayed, then the boolean was un-set. And at the very top of the submit action it would just 'return' if it saw the boolean. Maybe it will make more sense if you look at the submit event handler.
[More]
First up was Server.cfc. However that is a bit of a misnomer. You can actually point the administrator to any CFC. That CFC simply needs to have an onServerStart() method. This should be quite a boon for getting sites that have an expensive (read "slow") first request all spun up and ready for traffic.
Next up was nested cftransaction. Not a lot to explain here. From what I saw, it should satisfy you if you ever said to yourself "I really wish I could nest transactions in CF".
Then we got introduced to cffinally/finally. I personally have never used this even in languages that I have access to it. Basically it gives you this syntax: "try { ... } catch (e) { ... } finally { ... }". If someone wants to explain an compelling use case for "finally", I would love to hear it...
And then there was cfcontinue and it was good. Seriously! I mean, I'm excited about this one and at the same time amazed it took them this long.
[More]
Peter looks at projects in roughly 3 categories.
- Configuration < $8000 - free spec (just set up something already built)
- Customization < $50,000 - paid spec (requirements gathering, setting up and customizing packages)
- Exploration $50,000 - no spec (hard to even define scope)
Configuration
These projects are all about efficiency. You will need to simplify the specs for these types of projects. You will need to have/use configurable code to implement deliverable. That could be via something with a setting file or configuration wizard. In some cases you might use DSLs (domain specific languages). And for very simple stock types of things you can even reuse prior specification documents (copy and paste, or compile stock specs as you go).
Customization
I think here he was talking about a site that will use a lot of code that you or someone else already wrote.
[More]
May 28, 2009 10:46 AM
| Chris P.
Categories :
ColdFusion
I ran some test code the other day just to make sure that I correctly understand how arguments passed in to functions in CFML work. If you know everything there is to know about functions and arguments in ColdFusion, then feel free not to read the rest of this. But, if you're curious...
Here is the code:
<cfoutput>
<cffunction name="ExtraArgs" access="public" returntype="string">
<cfargument name="Arg1" required="false" type="string" />
<cfargument name="Arg2" required="false" type="string" />
<cfargument name="Arg3" required="false" type="string" />
<cfargument name="Arg4" required="false" type="string" />
<cfif structKeyExists(arguments,'Arg4')>
<cfreturn arguments.Arg4 />
<cfelse>
<cfreturn 'undefined' />
</cfif>
</cffunction>
<cfset args3 = {Arg1='value1', Arg2='value2', Arg3='value3'} />
<cfset args4 = {Arg1='value1', Arg2='value2', Arg3='value3', Arg4='value4'} />
<br/> 1) #ExtraArgs(argumentCollection=args3)# <!--- output = "undefined" --->
<br/> 2) #ExtraArgs(argumentCollection=args4)# <!--- output = "value4" --->
<br/> 3) #ExtraArgs(argumentCollection=args4, Arg4='SomeOtherValue')# <!--- output = "SomeOtherValue" --->
</cfoutput>
All of the arguments are specified as 'not required' with no 'default' value. The function looks for the existence of the fourth argument and either returns that or the string "undefined".
The first time it is called with the "args3" struct that omits the "Arg4" argument, it returns "undefined".
The second time it is called with the "args4" struct, which contains "Arg4", it returns "value4" (the value of "Arg4" in the args4 struct).
The third time it is called with the "args4" struct and also the "Arg4" argument in addition to that, it returns "SomeOtherValue". This, I think, is the most interesting one. With this behavior, you could store structs containing the default arguments for certain operations, and then call those operations overriding defaults as needed.
This is just a short post to share some JavaScript that I wrote to be able to add a drag corner to an html element to make it resizable.
I did this using prototype.js. As an example the two divs below have been made resizable. (Go ahead. Drag the bottom right corner around.)
And below is the code that makes it possible. If you take a look at it and read the comments, You'll see that it's actually pretty simple. The thing that had me stuck for a while was asking Prototype how tall or wide something is isn't the whole story. Border and padding add to width and height. I have some code in there that will compensate for that. However, I only covered situations where the border/passing were uniform all the way around. Anyway, love to hear what you think about this.
<div id="SomeDiv" style="position: relative; width: 200px; height:100px; border: 2px solid black; padding: 3px;">
Div One
<div class="corner" id="DragHandle"> </div>
</div>
<div id="DivTwo" style="position:relative; width:150px; height:75px; border:1px dashed red;">
Div Two
<div class="corner" id="DragHandleTwo"> </div>
</div>
<script type="text/javascript" language="javascript">
function DragCorner(container, handle) {
var container = $(container);
var handle = $(handle);
/* Add property to container to store position variables */
container.moveposition = {x:0, y:0};
function moveListener(event) {
/* Calculate how far the mouse moved */
var moved = {
x:(event.pointerX() - container.moveposition.x),
y:(event.pointerY() - container.moveposition.y)
};
/* Reset container's x/y utility property */
container.moveposition = {x:event.pointerX(), y:event.pointerY()};
/* Border adds to dimensions */
var borderStyle = container.getStyle('border-width');
var borderSize = borderStyle.split(' ')[0].replace(/[^0-9]/g,'');
/* Padding adds to dimensions */
var paddingStyle = container.getStyle('padding');
var paddingSize = paddingStyle.split(' ')[0].replace(/[^0-9]/g,'');
/* Add things up that change dimensions */
var sizeAdjust = (borderSize*2) + (paddingSize*2);
/* Update container's size */
var size = container.getDimensions();
container.setStyle({
height: size.height+moved.y-sizeAdjust+'px',
width:size.width+moved.x-sizeAdjust+'px'
});
}
/* Listen for 'mouse down' on handle to start the move listener */
handle.observe('mousedown', function(event) {
/* Set starting x/y */
container.moveposition = {x:event.pointerX(),y:event.pointerY()};
/* Start listening for mouse move on body */
Event.observe(document.body,'mousemove',moveListener);
});
/* Listen for 'mouse up' to cancel 'move' listener */
Event.observe(document.body,'mouseup', function(event) {
Event.stopObserving(document.body,'mousemove',moveListener);
});
}
DragCorner('SomeDiv','DragHandle');
DragCorner('DivTwo','DragHandleTwo');
</script>