CFMAIL To Multiple Recipients

From:cfsilince
Link: http://cfsilence.com/blog/client/index.cfm/2006/12/12/Sending-CFMAIL-To-Multiple-Recipients
Basic stuff, but I think sometimes we overlook the small easy stuff

<!--- create a fake query --->
<cfset q = queryNew("emailAddress")>
<cfset queryAddRow(q, 2)>
<cfset querySetCell(q, "emailAddress", "me@you.com", 1)>
<cfset querySetCell(q, "emailAddress", "you@us.com", 2)>

<!--- set up variables --->
<cfset variables.msg = "this is a test">
<cfset variables.subject = "test subject">
<cfset variables.from = "admin@coldfusionites.com">

<cfmail from="#variables.from#" subject="#variables.subject#" query="q" to="#emailAddress#">
#variables.msg#
</cfmail>

Passing certain URL variables to a SWF within a ColdFusion.

From: rabidGadfly

Using SWFObject to place my Flash objects.

customvars=user_id,123456;eyecolor,blue;car,accord

Then, in my CF page I put the following code which converts the customvars string into a CF structure:

<cfset flashVars = structNew() />
<cfparam name="url.customvars" default="">
<cfif len(url.customvars)>
<cfloop list="#url.customvars#" delimiters=";" index="customFlashVar">
<cfset thisRecordName = listFirst(customFlashVar,",")>
<cfset thisRecordValue = listLast(customFlashVar,",")>
<cfset flashVars[thisRecordName] = thisRecordValue>
</cfloop>
</cfif>

Then, in my swfObject code, I loop through the structure assigning the name and variable to swfObject's addVariables like this:

<cfloop collection="#flashVars#" item="key">
fo.addVariable("#key#","#attributes.parms[key]#");
</cfloop>

How to install Eclipse Java Development Tools in Flex Builder 2 stand-alone

Here are the steps to install Eclipse Java Development Tools in Flex Builder 2 stand-alone. I haven't really tested yet, but it installs properly and I'm able to open the Java development perspective.

1. Help > Software Updates > Find and Install...

2. Search for new features to install.

3. Select Eclipse.org update site, then click Finish.

4. Expand Eclipse.org update site > Eclipse 3.1.2.

5. Select Eclipse Java Development Tools 3.1.2, then click Next.

6. Accept the license agreement, then click Next.

7. Click Finish.

8. After JDT is downloaded, click Install.

9. Restart your workbench when prompted.

10. Start writing code!

Fro on Using ColdFusion to transform XML with XSLT

Fro's post link: here

Working with XSLT to transform XML documents for a new project.

For this example I'll use the RSS 2.0 format. First we have to create the XML that we're going to transform. You could read in an XML file using any normal method (cffile, cfhttp, etc.). I'll just create my own using cfxml. I used the RSS 2.0 example from Wikipedia.

<cfxml variable="myRSS">
<rss version="2.0">
<channel>
<title>Liftoff News</title>
<link>http://liftoff.msfc.nasa.gov/</link>
<description>Liftoff to Space Exploration.</description>
<language>en-us</language>
<pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate>
<lastBuildDate>Tue, 10 Jun 2003 09:41:01 GMT</lastBuildDate>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<generator>Weblog Editor 2.0</generator>
<managingEditor>editor@example.com</managingEditor>
<webMaster>webmaster@example.com</webMaster>

<item>
<title>Star City</title>
<link>http://liftoff.msfc.nasa.gov/news/2003/news-starcity.asp</link>
<description>How do Americans get ready to work with Russians aboard the International Space Station? They take a crash course in culture, language and protocol at Russia's Star City.</description>
<pubDate>Tue, 03 Jun 2003 09:39:21 GMT</pubDate>
<guid>http://liftoff.msfc.nasa.gov/2003/06/03.html#item573<;/guid>
</item>

<item>
<title>Space Exploration</title>
<link>http://liftoff.msfc.nasa.gov/</link>
<description>Sky watchers in Europe, Asia, and parts of Alaska and Canada will experience a partial eclipse of the Sun on Saturday, May 31st.</description>
<pubDate>Fri, 30 May 2003 11:06:42 GMT</pubDate>
<guid>http://liftoff.msfc.nasa.gov/2003/05/30.html#item572<;/guid>
</item>

<item>
<title>The Engine That Does More</title>
<link>http://liftoff.msfc.nasa.gov/news/2003/news-VASIMR.asp</link>
<description>Before man travels to Mars, NASA hopes to design new engines that will let us fly through the Solar System more quickly. The proposed VASIMR engine would do that.</description>
<pubDate>Tue, 27 May 2003 08:37:32 GMT</pubDate>
<guid>http://liftoff.msfc.nasa.gov/2003/05/27.html#item571<;/guid>
</item>

<item>
<title>Astronauts' Dirty Laundry</title>
<link>http://liftoff.msfc.nasa.gov/news/2003/news-laundry.asp</link>
<description>Compared to earlier spacecraft, the International Space Station has many luxuries, but laundry facilities are not one of them. Instead, astronauts have other options.</description>
<pubDate>Tue, 20 May 2003 08:56:02 GMT</pubDate>
<guid>http://liftoff.msfc.nasa.gov/2003/05/20.html#item570<;/guid>
</item>
</channel>
</rss>
</cfxml>
Next we have to create the XSTL that will be used to transform the RSS feed. I used the XSLT reference guide from zvon.org as my main reference while putting together this XSTL. Check it out if you need help with XSLT. Like the XML above, you could read in the XSLT many different ways. I'll just create it via cfsavecontent. If you're running 7.0+ you can use cfxml. For some reason, it didn't work in 6.0.
<cfsavecontent variable="myXSL">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xhtml" indent="yes" omit-xml-declaration="yes" />
<xsl:template match="/rss/channel">
<xsl:element name="h1">
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="link" /></xsl:attribute>
<xsl:value-of select="title" />
</xsl:element>
</xsl:element>

<xsl:for-each select="item">
<xsl:element name="h2">
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="link" /></xsl:attribute>
<xsl:value-of select="title" />
</xsl:element>
</xsl:element>

<xsl:element name="p">
<xsl:value-of select="description" />
</xsl:element>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
</cfsavecontent>
So we have the XML (RSS) and our XSLT. All we have to do now is use ColdFusion's XMLTransform() function and output our results.
<cfset myOutput = xmlTransform(myRSS, myXSL) />
<cfoutput>#myOutput#</cfoutput>
That's really all there is to it. Pretty easy, right. This is just a basic example. Just imagine what else you could do with it.

I want to end this by saying that you don't need CF to use XSL transformations. You can use XSL stylesheets directly in your XML documents. Check out some of these resources.

http://www.w3schools.com/xml/xml_xsl.asp
http://www.xmlfiles.com/xsl/
http://www.w3.org/Style/XSL/

Ray Camden on SES style URLs

From: ray camden blog

Link: Here

CGI.PATH_INFO is a CGI variable that will represent any information found after the filename in the URL. Look at the URL in the browser. Notice the index.cfm is followed by a / and then various bit of information. What I did for BlogCFC was create a specific pattern, and then wrote some code to parse that pattern and load various groups of blog entries (or A blog entry) based on the value. I could have also done something a bit more generic of the form:

/name1/var1/name2/var2

In this pattern, I've changed name1=var1&name2=var2 to a simpler list of name/value pairs. We can use the same pattern with Model-Glue, but since Model-Glue uses an event value, we need to preface it with the event to run. So the pattern I will use is:

/event/name1/var1/name2/var2

I opened up my Application.cfm file and added the following code:

<!--- get the info --->
<cfif len(trim(cgi.path_info))>
<!--- From Michael Dinowitz --->
<cfset urlVars=reReplaceNoCase(trim(cgi.path_info), '.+\.cfm/? *', '')>
<cfif urlVars is not "" and urlVars is not "/">
<!--- remove first / --->
<cfif left(urlVars, 1) is "/">
<cfset urlVars = right(urlVars, len(urlVars)-1)>
</cfif>
<!--- Event is first item --->
<cfset url.event = listFirst(urlVars, "/")>
<!--- strip it off --->
<cfset urlVars = listRest(urlVars, "/")>
<!--- now build name/val pairs --->
<cfloop index="x" from="1" to="#listlen(urlVars,"/")#" step="2">
<cfset name = listGetAt(urlVars, x, "/")>
<cfif listLen(urlVars, "/") gte x+1>
<cfset value = listGetAt(urlVars, x+1, "/")>
<cfelse>
<cfset value = "">
</cfif>
<cfset url[name] = value>
</cfloop>
</cfif>
</cfif>

[More]

ColdFusion 8 - code name: Scorpio Final Logo

I was contacted by the ColdFusion Sr Product Marketing Manager at Adobe, Tin Buntel with the great news than the ColdFusion team had choosen the design of the logo I had submited to them to use in the next major release of ColdFusion - code branding product named Scorpio.

I'm glad to contribute in one way or another.

Logo Coldfusion Scorpio

Another Scorpio logo ...

Tools used: Firework

Logo Coldfusion Scorpio

ColdFusion 8 -code name: Scorpio- Logo Submissions ...

Tools used: Firework

CFC Best Practices

CFC Best Practices from: http://www.massimocorner.com/

This document is intended to be a concise summary of best practices everyone building CFCs should be aware of. For a more thorough review of best practices, be sure to check out the ColdFusion MX Coding Guidelines created by Sean Corfield. GLOBAL RULES Always, always, always use "var" for local variables inside your methods, including ALL loop counters and temporary variables In general, only allow access to data associated with a CFC ("private data") via methods rather than through direct manipulation of "public" data members. Public data members break the separation of implementation from interface. Two primary benefits of maintaining encapsulation with methods are: You can keep the exposed API the same while changing how your CFC works internally without breaking any code that uses your CFC. Prevents the developer from getting in trouble by violating your internal assumptions about how the instance data works. For example, these are good:

foo = myCFCInstance.getInterestingStuff() myCFCInstance.setInterestingStuff(foo)

and these are bad:

foo = myCFCInstance.interestingStuff myCFCInstance.interestingStuff = foo. Never use "this" when you mean private data (see above) -- that's what the "variables" scope is for. Either ALWAYS or NEVER explicitly scope references to "arguments" -- but, do not mix and match scoping and not scoping arguments. It can cause unexpected name collisions with the methods local scope because when a method is called the arguments are copied into the local scope automatically by ColdFusion. This author recommends choosing ALWAYS over NEVER in this case. Always (with rare exceptions) use OUTPUT="false" in your CFFUNCTION and CFCOMPONENT tags. Do not output directly to the buffer inside a CFC method -- instead return a string. The main reason is that you don't want to break encapsulation. By outputting directly to the output stream you assume knowledge of the external environment of the CFC, whereas if you return a string you get the exact same behavior when you do simply "#myCFC.someHTMLGeneratingMethod()#" but you gain the advantage of not assuming that's how your method will be used (for instance, what if the method that returns the string is used inside of a big CFSCRIPT block where someone is building a string via concatenation?). The other reason is that if you are not even trying to output text you'll end up with unwanted white space if you don't use OUTPUT="false". Use the "hint" attribute on CFCOMPONENT/CFFUNCTION/CFARGUMENT in almost most cases, to aid documentation (particulary for public methods) Use the RETURNTYPE attribute of CFFUNCTION and the TYPE attribute of CFARGUMENT to aid documentation and for runtime type checking. And don't forget that "void" is the RETURNTYPE when not returning anything. NOTE: there is minor performance penalty to TYPE and RETURNTYPE, so omit if you are squeezing miliseconds (something that is almost never necessary). Do not directly refer to external variables (i.e.: session/application variables) inside a CFC. When in doubt, preserve encapsulation. The one exception is when building facades, especially for web services/flash remoting, in which case ALL references to shared scope variables should be encapsulated within the facade. This means, for instance, passing in the dsn instead of referring to application.dsn when doing database queries. In general, non-required arguments of a CFC method should have a DEFAULT specified. Use "EXTENDS" only when describing an "is-a" relationship, not for a "has-a" relationship or for code reuse. For a nice summary, visit http://cnx.rice.edu/content/m11709/latest/ OPTIONAL, BUT WELL WORN PRACTICES Always have an init() method that acts as your constructor and returns "this" (unless you are building a web services/flash remoting facade). For instance data, create a "virtual scope" inside the VARIABLES scope. For instance, in the first line of your init() method you might have:

(some people like to call it "variables.my" instead). You can then reference your instance data as "instance.foo". The benefit is that it separates your stateful instance data from the VARIABLES scope, which also contains references to all methods (public AND private) as well as a reference to "THIS" -- this becomes really handy if you need to do things like return a memento of your instance or do global operations on all instance data. It's also very handy if and when you need to clone a CFC, since you can move state data in one chunk rather than worrying about which keys in VARIABLES are your instance data and which are built-in keys. You would likely still use the VARIABLES scope for non-stateful instance data such as references to other CFC's your instance uses. THINGS TO KEEP IN MIND Variable pass in and out of components by reference or by value based on the same rules as the rest of CFML. For instance, strings, arrays, numbers, and dates all pass by value, but structures, queries, and all other "complex" objects (including CFC instances) pass by reference. Duplicate() and CFWDDX do not work on CFC instances. When extending a component outside the base component's package, the sub-component does not inherit package permissions -- thus, you cannot call "package" methods on other CFCs in the package of the base component from the sub-component. You can have a method that has a RETURNTYPE or an argument that has a TYPE of a base component and return any component that extends that base component. For example, if methodA takes an argument "foo" of type "motorVehicle" and you pass "foo" as an instance of "car" (which extends "motorVehicle") then "methodA" will honor that "car" is a "motorVehicle" when doing type checking on the argument "foo".

Code

This template has a slight twist to it and that is that it includes no images what-so-ever. This results in a page which loads lightning fast and displays consistently on various browsing mediums.
<cfset lastDate = "">
   <cfset allowTB = application.blog.getProperty("allowtrackbacks")>
   <cfset maxEntries = application.blog.getProperty("maxEntries") />
   <cfoutput query="articles" startrow="#url.startrow#" maxrows="#maxEntries#">
      <div class="entry<cfif articles.currentRow EQ articles.recordCount>Last</cfif>">
      <cfif allowTB>

BloggArt  |  Portfolio  |  Contact          BloggArt is running BlogCFC version 5.5.