<rss version="2.0">
			<channel>
			<title>RIA CFML Flex Flash</title>
			<link>http://www.cfcdeveloper.com/index.cfm</link>
			<description>Adobe RIA Development</description>
			<language>en-us</language>
			<pubDate>Fri, 10 Sep 2010 04:42:02 -0700</pubDate>
			<lastBuildDate>Mon, 08 Feb 2010 12:46:00 -0700</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>clint317@cfcdeveloper.com</managingEditor>
			<webMaster>clint317@cfcdeveloper.com</webMaster>
			
			
			
			
			
			<item>
				<title>GraniteDS for Flex 3 and Glassfish</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2010/2/8/GraniteDS-for-Flex-3-and-Glassfish</link>
				<description>
				
				Is it just me or is GraniteDS just too complicated? I&apos;m an expert using FMS Flash Media Server and I understand BlazeDS but Granite Data Services is beyond plug-n-play. First, what is the stack and why is it hard to figure out? Tide, EJB, Gravity, Pojo, Seam, Spring, Guice, etc..

I have Glassfish v3 installed on my Windows PC along with MySQL and I want to create a Flex 3 application that uses GraniteDS 2.0.x with consumer and publisher, possibly along with Cairngorm Enterprise and no, I do not want an example, I want steps. I&apos;m using Eclipse with Flex 3 plugin, and I don&apos;t want to use Maven or Gas3.

1. How do I get GDS installed on the Glassfish server so that I have a gateway (http://xxxxxx/graniteamf/amf), what files, how and where to put them, etc..
2. Do I use Gravity? Tide? EJB? etc..
3. What are all of the configuration pieces and minimum params?

I&apos;ll take anything I can get to work locally that touches GDS for real time data services with push. I&apos;ve read everything I can online including the GDS web site and can not find a clear concise simple step by step tutorial or documentation. And if I ever figure it out I will certainly write a tutorial for my blog; sadly it&apos;ll be the only clear tutorial available.

So if anyone can tell, show, or point me to the right location, thank you. And I have to warn you, for over 2 weeks now I have tried everything I can find with no success. Please help.
				
				</description>
				
				<category>Eclipse &amp;amp; CFEclipse</category>
				
				<category>Flex/Flash/AS3</category>
				
				<category>Frameworks</category>
				
				<pubDate>Mon, 08 Feb 2010 12:46:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2010/2/8/GraniteDS-for-Flex-3-and-Glassfish</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Adobe Misses Flex Boat</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2010/2/2/Adobe-Misses-Flex-Boat</link>
				<description>
				
				It&apos;s my opinion that Adobe is making a mistake renaming Flex Builder to Flash Builder. Simply put, when it comes to business applications, businesses still don&apos;t want to buy a Flash solution. Adobe should catch this wave created by the Flex craze and call it just that, Flex.
				
				</description>
				
				<category>Bits and Bytes</category>
				
				<category>Eclipse &amp;amp; CFEclipse</category>
				
				<category>Flex/Flash/AS3</category>
				
				<category>Frameworks</category>
				
				<category>Personal</category>
				
				<pubDate>Tue, 02 Feb 2010 19:51:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2010/2/2/Adobe-Misses-Flex-Boat</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>MVC - Structured View Layer Development</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2009/9/8/MVC--Structured-View-Layer-Development</link>
				<description>
				
				Is it me or is the view layer in the MVC pattern being ignored or at least understated? Working on my most recent project I stepped up my MVC and OO emphasis during development and noticed that we, web developers, aren&apos;t doing anything structured as far as view development goes, at least I can&apos;t find anything searching the net. We conform the underlying complexities, like the model layer, into formal design and standards (OO for instance) but don&apos;t hold the view to the same or comparable expectations. We make sure that the view layer is seperated from business logic at the layer level but when it all comes together at the view level we fail to make anything formal out of that. I&apos;m attempting here to formalize and structure my view layer borrowing my experience in MVC and OO methodologies. It may be done already somewhere else but I can&apos;t find it and I need it, so here it is, right or wrong it&apos;s a jumping point.

If you look at the view layer in an object oriented approach and formalize the views as pseudo classes you may be able to deduce where I&apos;m headed. For example, views or pages have properties and methods that can be used to create UML class diagrams during the design phase. In addition you can carry these through the implimentation phase and realize the seperation within your page view code. The view is more than just the HTML layout of tables and div tags where content sits, it&apos;s a layer, not just a file. We already seperate CSS, Javascript, and other like concerns but not the inner page code structure, and I&apos;m not just refering to physical speration. It&apos;s just assumed that by the time you get to the actual view programming that you&apos;ll be able to just do it, no planning or formal organization required.

I&apos;m not talking about architecting the view in an object oriented manner, that&apos;s just too much. I believe the view can benefit from organized structuring of page concern seperation and we want to use this technique in planning and in coding. To demonstrate this I&apos;m going to create a simple and quick fictitous site with a few views in an MVC structured application.

Here&apos;s a draft of a UML class diagram showing how I might plan my views and view layers on paper. Notice that my page views are now represented as classes with properties and methods. Keep in mind that UML diagrams and planning is an iterative process and will change quite frequently but, we must start somewhere.

&lt;center&gt;&lt;img src=&quot;/enclosures/viewUML.gif&quot; /&gt;&lt;/center&gt;

Notice first the hirarchy from Application through layout and to individual nested pages. These are connected to show how each page view inherits it&apos;s elements from upper view layers. I&apos;m not advocating that this is the right way to diagram or think of it, just my way for now.

The application node is the top node here and has properties and methods you should recognize. This sits in the view layer in an inner application layer. An application layer in my mind can also include other nodes like UDF and configuration files.

Inner view layers:

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Container layer - the top most containing layer surrounding all other inner view layers in an application. All other view layers inherit from the application layer.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;HTML layer - Defines containers and layout structures in which to place content.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Content layer - Contains the content of page views and any externally viewable content media they may include.

My site has a default_layout page that displays content layers, and as usual frequently repeated elements across multiple views are located here too; ie the header, footer, and navigation. Notice it&apos;s properties here. The value for jsDir will be the physical path that will be used in the source attribute of a script tag or anywhere else we may find a need for it. For example:
&lt;code&gt;&lt;$cript type=&quot;text/javascript&quot; src=&quot;&lt;cfoutput&gt;#jsDir#&lt;/cfoutput&gt;ddlevelsmenu.js&quot;&gt;&lt;/code&gt;

The homeLink property has a value equal to the actual href tag, the link back to the home page. And in this property we can edit the link as needed from one easy to find location in this view. The default layout view here also composes of the CSS, the JavaScripts, and anything else you would need to include somehow. These inclusions, not expanded here, could be psuedo classes with properties and methods as well.

Moving down the view layer we have the content layer view nodes which is the meat of our site to the user. They inherit properties and methods of the layout layer as well as defining their own. In this diagram we can see what the content views inherit, most useful when trying to remember what your content view pages are capable of before any code goes into it.

Starting with the home content view I created a userListLink property containing the href link to the userList content view. That property can be used anywhere in the home content view.

Next, the userList content view will output a list of users that we retrieved from the control layer after being queried and cast to an array in the model layer. So the users array will be a property of array type. Notice I don&apos;t type simple properties such as strings. There are two other properties, listPerPage (how many to paginate per page), and userDetailLink which is the href for the link to the userDetail content view. Here we also have methods for this view.

The userCountTotal() function placed here for example is a simple function the view can call from anywhere to get a value. And no matter where or how many times this function is placed it can be altered from one location.

Let&apos;s take for example the next function, wTitle(), to see how this works in practical code. The purpose of this function is to encapsulate a piece of content and seperate it from the views tables and divs, making the design much easy to read, move around, and format. The best way to show this is probably a before and after example.

Before using view layering:
&lt;code&gt;&lt;cfsilent&gt;
&lt;cfscript&gt;
users = event.getValue(&apos;users&apos;);
listPerPage = getController().getSetting(&apos;listPerPage&apos;);
userDetailLink = &quot;&lt;a href=&apos;&apos;&gt;View Details&lt;/a&gt;&quot;;
catagory = event.getValue(&apos;catagory&apos;);
&lt;/cfscript&gt;
&lt;/cfsilent&gt;
&lt;cfoutput&gt;
&lt;div class=&quot;centerPadding&quot;&gt;
&lt;span class=&quot;largetext&quot; style=&quot;text-transform:capitalize;&quot;&gt;&lt;strong&gt;#catagory#&lt;/strong&gt; readings&lt;/span&gt;
&lt;br /&gt;
&lt;span class=&quot;smalltext&quot;&gt;Always only $2.99 per minute!&lt;/span&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;table width=&quot;100%&quot; cellspacing=&quot;0&quot; cellpadding=&quot;3&quot; border=&quot;0&quot;&gt;
&lt;tr&gt;
...&lt;/code&gt;

After using view layering:
&lt;code&gt;&lt;cfsilent&gt;
&lt;cfscript&gt;
users = event.getValue(&apos;users&apos;);
listPerPage = getController().getSetting(&apos;listPerPage&apos;);
userDetailLink = &quot;&lt;a href=&apos;&apos;&gt;View Details&lt;/a&gt;&quot;;
catagory = event.getValue(&apos;catagory&apos;);
function wTitle(){
writeoutput(&quot;
&lt;span class=&quot;&quot;largetext&quot;&quot; style=&quot;&quot;text-transform:capitalize;&quot;&quot;&gt;&lt;strong&gt;#catagory#&lt;/strong&gt; users&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;&quot;smalltext&quot;&quot;&gt;List of all users from the #catagory# catagory.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;
&quot;);
}
&lt;/cfscript&gt;
&lt;/cfsilent&gt;
&lt;cfoutput&gt;
&lt;div class=&quot;centerPadding&quot;&gt;
#wTitle()#
&lt;table width=&quot;100%&quot; cellspacing=&quot;0&quot; cellpadding=&quot;3&quot; border=&quot;0&quot;&gt;
&lt;tr&gt;
...&lt;/code&gt;

Notice how we took out a huge chunk of content making the layout much easier to conceptualize and edit. This also lends to seperating concerns for content programmers and design layout artist. In making these separate I usually rule out any chunks that are either small or contain more layout code such as td repeaters. All I want to be left with below the content functions is basically a skeleton of table and div tags.

The userDetail content layer view has two properties. User is a user object passed in from the controller and the userListLink is an href string used to link back to the userList node. There are two functions used to output content, wUserImage() is the code to output the image for the user. The wUserDescription() function is called to format and place the description block how and where you would like. Think of these functions as an easy way for a layout artist to place content within his work that the content programmer has already developed. These functions could also take in arguments if the programmer feels witty. Then a view layer API can be documented and used by the design artist.

What I&apos;m doing inside the views to seperate content and layout design isn&apos;t as important as the benifits realized from the view layer model in the design phase. The other models such as those in the model layer can now be associated with nodes in the view layer. Eventually I want to produce a document where every element that is a part of the process can be modeled to and from each other and between layers in a world view type map.

It&apos;s all pretty simple and not well thought out for now, the result of about a day of thinking. I do plan to expand it if I can&apos;t find anything comparable out there. For now it seems to help me a lot with organizing and visualizing page views. Esspecially when you consider that I&apos;m already thinking this way for the other layers.
				
				</description>
				
				<category>OOP/Patterns</category>
				
				<category>Frameworks</category>
				
				<category>ColdFusion</category>
				
				<pubDate>Tue, 08 Sep 2009 11:05:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2009/9/8/MVC--Structured-View-Layer-Development</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Generating and using site documentation, cfcdoc</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2009/9/6/Generating-and-using-site-documentation-cfcdoc</link>
				<description>
				
				I&apos;m completely embarrased to admit it but, I didn&apos;t know until yesterday that not only can I create my own web site&apos;s API documentation automatically but how useful it can be. Sure beats glazing over my directories and trying to remember where everything is and what it does.

My latest project has got me dealing heavily with application API&apos;s and it&apos;s important to read and understand how to apply the API to development, especially when using OO framework architectures. Reading and using the API&apos;s for my Coldbox framework (&lt;a href=&quot;http://www.coldboxframework.com/api/&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;) I got to thinking that having this documentation for my own site would be very useful and very cool. It literally puts OO into perspective, for me anyways since I like the API&apos;s, and helps me to visualize how my classes (components) are organized, if anything is out of place, and if I can optimize anything.

At first I was using the CFIDE component utilities (localhost:8300/cfide/componentutils/) like the explorer and the componentdoc. But it would always list packages from everywhere, including the CFIDE and WEB-INF folders. And then it would list the pakages from the mappings as well as the folder it pointed to. So I edited the code to exclude folders, thinking that there&apos;s got to be a better way, and there was. Looking back at Coldbox&apos;s API I notice it&apos;s from an open source RIAforge thing, get it here: &lt;a href=&quot;http://cfcdoc.riaforge.org/&quot; target=&quot;_blank&quot;&gt;CFCDoc&lt;/a&gt;. It&apos;s so easy, just extract the zip to your root under a folder, like &apos;/api/&apos; and go there. There&apos;s information about what to do next because all the packages you&apos;ll see at first are the one&apos;s in the /api/ folder you placed it in, not very useful. But basically you add or delete folders to include through a simple config xml file and that&apos;s it, your exploring your very own API.

Depending on the length you want to go to in your documentation you can go really wild with component and function attributes like hint and displayname, probably more too. Using these extra attributes I&apos;m sure you thought were useless and time consuming you can add enough information to make the API a virtual users manual. At the very least you can use the API to match up with your UML class models. I&apos;m thinking also that planning a site&apos;s structure could be done API style instead of UML style, maybe even faster. You can think of what classes you need and how to package them for your application doing API visualization. In other words, what should your API look like and is it all packaged logically from an API documentation perspective?
				
				</description>
				
				<category>Resources</category>
				
				<category>OOP/Patterns</category>
				
				<category>Frameworks</category>
				
				<category>ColdFusion</category>
				
				<pubDate>Sun, 06 Sep 2009 09:17:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2009/9/6/Generating-and-using-site-documentation-cfcdoc</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Do ColdFusion programmers need to be object oriented gurus?</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2009/9/4/Do-ColdFusion-programmers-need-to-be-object-oriented-gurus</link>
				<description>
				
				Before I begin let me just say that although I&apos;m not a certified Java developer, which would make me an automatic OO guru, I do develop Flash and Flex applications using AS3, which is an OO language. Yes, when it comes to OO I know what I&apos;m talking about and have studied and used patterns for a few years. I&apos;m not a pure OOist but who is and who really needs to be?

I&apos;m so tired of chasing that alusive brass CFOOP ring of knowledge, trying to become a an object oriented guru with the deepest depths of understanding. I&apos;m already there and so are you, seriously, its not as far as you thought. And I&apos;m talking to CF verterans that use cfc&apos;s as objects, and patterns (whether they know it or not) to solve problems. You may not be using pure OO but you are OOing purely enough. For those reading this that know nothing of OO please stop and go read a few beginner OO basic articles and then come back.

There&apos;s only about a 10% difference between OO in an &quot;OO language&quot; like Java, and OO in the ColdFusion scripting language. And that 10% difference is used about 1% of the time. So you can&apos;t create interfaces (technically you can with underlying Java), big deal, and completely irrelevant too. Creating &quot;I&quot; classes is simply rewriting the original class in a more impressive way and there&apos;s only a 1% chance you&apos;ll actually need the real thing. Interfaces for the most part are for compile time error checking and CF is not a compile time language, not at our level it isn&apos;t.

Let&apos;s see, what else is there that I&apos;ll probably never have a need for, or can do in some other CF way. Overloading, constructors, overriding, and multiple inheritance, and that&apos;s about it. As for the constructor, we use an init function on object instantiation as a consturctor for now but, CF 9 will have implicit constructors. Overriding can be accomplished in CF using composition. BTW, implicit getters and setters will be available in CF 9 also.

Other than the lack of multiple inheritence (which isn&apos;t a requirement to be considered a true &apos;OO capable&apos; language, like Java and Smalltalk), if Adobe added overloading capabilities then CFers could be concidered OOers too. And just like a Java coder can produce crappy non-OO code so can a CF coder create crappy non-OO CF code.

Here&apos;s the thing though, follow me. ColdFusion is a RAD tool that can be structured in an OO way following proper OO techniques. ColdFusion is OO when and if you need it to be but we certainly don&apos;t want it to be totally and purely OO, ever, EVER. If you make it pure OO say goodbye to rapid development and say goodbye to the market it is ment for. OO was devised to help solve complexed problems in very large systems, something that CF can but doesn&apos;t do much of. Those complexed and very large systems are far and few between, the market is in the average system, which don&apos;t need OO much any ways.

All that being said, if you&apos;ve got the jest of OO terminology down and have enough understanding of the underlying principles that you can apply it safely, stop worrying about it and get back to work. The only way you can become a better OOer is to practise it. And as for those Java guys laughing at us CFers when OO is mentioned, they&apos;re just trying to chase away the new kids in their OO sandbox, spoiled sports don&apos;t want to share the spotlight. Honestly I don&apos;t consider anyone an OO programmer based on the language he uses, it&apos;s how he uses the language that defines a programmers OO understanding. And if people will stop refering to CF as it was prior to the MX version we&apos;de stop having this debate in the first place. Once apon a time, ColdFusion couldn&apos;t be architectured with OO principles, but now it can. The end.
				
				</description>
				
				<category>Personal</category>
				
				<category>OOP/Patterns</category>
				
				<category>Frameworks</category>
				
				<category>Flex/Flash/AS3</category>
				
				<category>ColdFusion</category>
				
				<pubDate>Fri, 04 Sep 2009 11:25:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2009/9/4/Do-ColdFusion-programmers-need-to-be-object-oriented-gurus</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>ColdFusion OO, MVC, and Frameworks</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2009/9/1/ColdFusion-OO-MVC-and-Frameworks</link>
				<description>
				
				Saying that you don&apos;t need OO or MVC to build a ColdFusion application or web site is like saying you don&apos;t need blueprints and building code standards to build a skyscraper or a house. Granted, blueprints are overkill for a birdhouse but, OO and frameworks are overkill for a one product web site too. You should know when all the overhead is needed and when it is just going to be overhead. To me, it seems like this is the real problem when it comes to utilizing more sophisticated coding techniques rather than just plain old coding.

In all actuality most of the complaints, confusion, and questions come from weekend programmers who don&apos;t need to concern him or herself with such extremes. But they make a mountain out of a mole hill (or an application out of a web site in this case) because they want to hunt with the big dogs or think they need to or should, or they just feel inadaquite if they don&apos;t. I don&apos;t blame them, I did too, and I wouldn&apos;t be where I am today if I didn&apos;t venture into the world of software engineering. But all that stuff didn&apos;t add anything positive to my low level projects at the time except taking more time to do it, so be careful.

Here&apos;s the honest to goodness truth about using all that fancy stuff. Any site or application created using any of that overhead can be created just as well with straight down proceedural coding. The end user, and sometimes even the client wouldn&apos;t know the difference between one and the other unless you pointed it out and showed them. In all frankness, only about a quarter of web sites need to bother with anything more than simple code, yet three quarters of web developers think they should.

My advice to web development noobs is to stick with the one thing you need to get the job done unless and until that job requires more than what that language can do efficiantly on it&apos;s own. Who knows, you might develop a simple site that makes you a millionaire without ever knowing what OO is. But if that site begins to grow unwieldly with errors coming from nowhere, it&apos;s time to turn to more sophisticated techniques. It&apos;s time to use MVC, properly incorporate a framework, and maybe even learn some OO terms and patterns. Then the question &quot;when should I use the fancy stuff&quot; becomes &quot;how, what, and where do I use these&quot;.

Personally I use an MVC architecture on anything over a dozen pages, frameworks on anything with more than a few applications, and OOD/P on anything considered an enterprise. If you must, its important that you be able to do these things with professional precision to get something out of it. Your not going to get any ROI using a framework on any application if you&apos;ve never used one before, so don&apos;t practice where your paycheck comes from.

MVC is a term used to describe a seperation of concerns, the business model, the user interface, and the central controller. It&apos;s not a product and there is no one right way to do it. As long as the thinking is done in one place, the displaying done in another, and neither knows about the other except through a controller, your using proper MVC architecture. Pretty simple right? If you only have a few events, or page views, then yes it is.

But, try rolling your own MVC on a medium size project and you&apos;ll grow to appreciate frameworks rather quickly. A framework is basically an MVC, structured and expanded for medium to large scale projects. That is, it supports agile development by not only insuring best practise MVC organization, but also offers commonly used programming logic in prebuilt API&apos;s. It&apos;s the foundation or base that will be the strongest part of your structured application if used properly. 

Object oriented programming basically helps when you can objectify parts of a program into seperate entities and only if there will be a lot of them. In addition it&apos;s only benificial if those parts will be very active during the life of the application. By active I don&apos;t mean the use of the application, I&apos;m talking about moving things around, enhancing them and depricating them, or allowing others to use them. If an object is going to be static in that regard, then it shouldn&apos;t be factored into the decision to use OO.

In summary, something important to think about while you hone your enterprise software engineering skills is that, as you get more comfortable with this sophisticated stuff you&apos;ll become more able to use those bigger skill sets on smaller scales. I for one find myself able to flesh out an OO UML model for a simple site in a matter of minutes. An OO noob might waste valuable precious days over the same thought with a negative ROI. So yes, you can use this stuff on smaller scales effectively when it becomes second nature and you don&apos;t have to think about how but what. As for all those naysayers that are swimming against the industry tide and trying to convince you that it&apos;s all uneccessary, they couldn&apos;t be more wrong. The storm is coming, mark my word. Maybe not in our life time but soon, developing web sites will be out of the range for the average Joe and the strongest of proceedural coders will be lost without keeping up. Stop pouting and start evolving, accept it, embrace it, love it.
				
				</description>
				
				<category>ColdFusion</category>
				
				<category>Frameworks</category>
				
				<category>OOP/Patterns</category>
				
				<category>Personal</category>
				
				<pubDate>Tue, 01 Sep 2009 16:19:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2009/9/1/ColdFusion-OO-MVC-and-Frameworks</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Consume object or object property</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2009/6/20/Consume-object-or-object-property</link>
				<description>
				
				Here it is in a nutshell. I have a controller cfc in my framework that directs execution instructions to the business model cfc&apos;s. But I&apos;m wandering if I should pass whole objects, like a user object, and get values as needed from it&apos;s methods within the business model? Or should I just pass the object&apos;s properties to the business model classes as needed?

Another way to put it is this(model/securityService.cfc):
&lt;code&gt;
instance.securityGateway.login(User.getUsername(),User.getUserpassword());

or

instance.securityGateway.login(User);
&lt;/code&gt;

The business model gateway in this example would be something like(model/data/gateway/securityGateway.cfc):
&lt;code&gt;
&lt;cffunction name=&quot;login&quot;..&gt;
&lt;cfargument name=&quot;username&quot;../&gt;
&lt;cfargument name=&quot;password&quot;../&gt;
...
&lt;/cffunction&gt;

or

&lt;cffunction name=&quot;login&quot;..&gt;
&lt;cfargument name=&quot;User&quot; type=&quot;model.data.gateway.User&quot;../&gt;
..
&lt;/cffunction&gt;
&lt;/code&gt;

Maybe because I&apos;m not a seasoned OO veteran but I&apos;m looking at this and trying to figure out the best course and can&apos;t decide which one to take. From the service cfc do I pass in the user object or it&apos;s properties (username &amp; password)?

For now I&apos;m passing the object&apos;s properties if the gateway method only requires data and doesn&apos;t need to access any of the objects other methods like setters. If the gateway method here needed to use the object&apos;s methods instead of just it&apos;s properties, then I&apos;d pass the entire object. So what do you think is best practice?
				
				</description>
				
				<category>Bits and Bytes</category>
				
				<category>Coldbox 2.6</category>
				
				<category>ColdFusion</category>
				
				<category>Frameworks</category>
				
				<category>OOP/Patterns</category>
				
				<pubDate>Sat, 20 Jun 2009 07:03:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2009/6/20/Consume-object-or-object-property</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>CFC Method Testing in Coldbox</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2009/5/20/CFC-Method-Testing-in-Coldbox</link>
				<description>
				
				I got tired of trying to get cfUnit working and all I wanted to do was test component methods. I wanted to be able to simply point to it, test it, and enter arguments if required. And I wanted this set up somewhere easy I could use quickly, repeatedly, effortlessly, and painlessly (word?).

In almost all my applications I have a &apos;webmaster&apos; directory where I run test. Lately I&apos;ve found myself getting fancy with setting up a web development control panel of sorts. Whereas web sites generally have administration control for admin users, I&apos;ve been building in webmaster control for developers. Mostly things like server and framework info, links to documentation, framework and site functionality examples, and etc.

Now I&apos;m adding a little CFC Test form where I enter my cfc path, the method name, and arguments. It will pass the event argument so you can also test cfc handlers.

Warning, I just created this a few hours ago. It&apos;s tested to work but I haven&apos;t cleaned it up or put in validation and error handling yet.

views/webmaster/index.cfm (webmaster control panel)
&lt;code&gt;&lt;cfform name=&quot;cfctestform&quot; action=&quot;#cgi.SCRIPT_NAME#&quot; method=&quot;post&quot; format=&quot;html&quot;&gt;
	&lt;cfinput name=&quot;do&quot; type=&quot;hidden&quot; value=&quot;webmaster.panelcontrol.testmethod&quot; /&gt;
	&lt;cfinput name=&quot;sbIsEnabled&quot; type=&quot;hidden&quot; value=&quot;0&quot; /&gt;
	Enter Component Path:&lt;br /&gt;&lt;cfinput name=&quot;cfcpath&quot; type=&quot;text&quot; /&gt;
	&lt;br /&gt;
	Enter Method to Test:&lt;br /&gt;&lt;cfinput name=&quot;cfcmethod&quot; type=&quot;text&quot; /&gt;
	&lt;br /&gt;
	Arguments:(comma seperated list)&lt;br /&gt;&lt;cfinput name=&quot;methodargs&quot; type=&quot;text&quot; width=&quot;80&quot; /&gt;
	&lt;br /&gt;
	&lt;cfinput type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Run Test&quot; /&gt;
&lt;/cfform&gt;&lt;/code&gt;

events/webmaster/panelcontrol.cfc (Coldbox handler)
&lt;code&gt;&lt;cffunction name=&quot;testmethod&quot; access=&quot;public&quot; returntype=&quot;void&quot; output=&quot;true&quot;&gt;
	&lt;cfargument name=&quot;Event&quot; type=&quot;coldbox.system.beans.requestContext&quot;&gt;
	&lt;cfset var rc 		= arguments.event.getCollection()&gt;
	&lt;cfset var ret 		= &quot;&quot;&gt;
	&lt;cfset var cfcObj 	= createObject(&quot;component&quot;,rc.cfcpath)&gt;
	&lt;cfif listLen(rc.methodargs)&gt;
		&lt;cfloop from=&quot;1&quot; to=&quot;#listLen(rc.methodargs)#&quot; index=&quot;i&quot; step=&quot;2&quot;&gt;
			&lt;cfset evaluate(&quot;arguments[&apos;#listGetAt(rc.methodargs,i)#&apos;] = &apos;#listGetAt(rc.methodargs,i+1)#&apos;&quot;)&gt;
		&lt;/cfloop&gt;
	&lt;/cfif&gt;
	&lt;cfinvoke component=&quot;#rc.cfcpath#&quot; method=&quot;#rc.cfcmethod#&quot; argumentcollection=&quot;#arguments#&quot; returnvariable=&quot;ret&quot;&gt;
	&lt;cfscript&gt;
		//Display
		event.setValue(&quot;cfctestresults&quot;,ret);
		event.setValue(&quot;author&quot;,&quot;Clint Willard&quot;);
		event.setView(&quot;webmaster/dspCfcTestResult&quot;);
	&lt;/cfscript&gt;
&lt;/cffunction&gt;&lt;/code&gt;
Basically it loops through the method arguments list you entered in the form setting them as part of the arguments struct. That arguments struct is then passed to the invoked component and method, along with the event object. Then the view is set to output with the test results, whatever the method is set to return.

views/webmaster/dspcfcTestResult.cfm
&lt;code&gt;&lt;cfscript&gt;
	cfcresult = event.getValue(&quot;cfctestresults&quot;,&quot;NA&quot;);
&lt;/cfscript&gt;
&lt;cfoutput&gt;
	#dump(cfcresult)#
&lt;/cfoutput&gt;&lt;/code&gt;
KISS output.

Let me know if this might be a good idea to expand on or should I just LOL learn cfUnit? And the webmaster information and control panel stuff?
				
				</description>
				
				<category>Coldbox 2.6</category>
				
				<category>ColdFusion</category>
				
				<category>Frameworks</category>
				
				<category>Resources</category>
				
				<pubDate>Wed, 20 May 2009 18:31:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2009/5/20/CFC-Method-Testing-in-Coldbox</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Coldbox Framework and Ajax: cfajaxproxy</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2008/10/16/Coldbox-Framework-and-Ajax-cfajaxproxy</link>
				<description>
				
				After working in Coldbox for a while I know your first instinct is to make a cfajaxproxy call to a cfc event just like all the other Coldbox events. However, using cfajaxproxy is just a little different. Here is an example to show you one simple way of doing it, not the only way but one of them.

First let me note that I am using Coldspring version of IOC. It should work the same though with any form of IOC. Mostly we need the IOC to provide the bean to the services your Ajax call requires from within the Coldbox proxy.

After having provided a service in Coldspring like so:
&lt;code&gt;
&lt;bean id=&quot;usersService&quot; class=&quot;model.usersService&quot;&gt;
  &lt;constructor-arg name=&quot;privatemessagesGateway&quot;&gt;
    &lt;ref bean=&quot;privatemessagesGateway&quot;/&gt;
  &lt;/constructor-arg&gt;
  &lt;constructor-arg name=&quot;ColdBoxController&quot;&gt;
    &lt;ref bean=&quot;ColdBoxController&quot;/&gt;
  &lt;/constructor-arg&gt;
&lt;/bean&gt;
&lt;/code&gt;

we can use this &quot;usersService&quot; bean in the coldboxproxy.cfc like this:
&lt;code&gt;
	&lt;cffunction name=&quot;ajxSetPMRead&quot; access=&quot;remote&quot; output=&quot;false&quot; returntype=&quot;void&quot;&gt;
		&lt;cfargument name=&quot;messageid&quot; type=&quot;String&quot; required=&quot;true&quot;/&gt;
		&lt;cfset var pm = getBean(&apos;usersService&apos;).getPrivateMessageByID(int(arguments.messageid))&gt;
		&lt;cfset pm.setRead(1)&gt;
		&lt;cfset getBean(&apos;usersService&apos;).savePrivateMessage(pm)&gt;
	&lt;/cffunction&gt;
&lt;/code&gt;

The code above is what the Ajax, cfcajaxproxy, will call as a method for Coldbox to perform. It fetches a private message object bean, sets or updates some properties, then uses the gateway to save the object bean. I don&apos;t have a return or output but you can do that also here if desired. And here is the actual view and Ajax calling code:
&lt;code&gt;
&lt;cfajaxproxy cfc=&quot;coldboxproxy&quot; jsclassname=&quot;cbProxy&quot;&gt;

&lt;a href=&quot;##&quot; onClick=&quot;showMessageDetails(&apos;#privateMessagesQuery.privatemessageid#&apos;,&apos;#privateMessagesQuery.read#&apos;,&apos;#privateMessagesQuery.subject#&apos;,&apos;#privateMessagesQuery.fromUserName#&apos;,&apos;#privateMessagesQuery.message#&apos;)&quot;&gt;#privateMessagesQuery.subject#&lt;/a&gt;

&lt;$cript&gt;
function showMessageDetails(messageid,read,subject,from,message){
	var e = new cbProxy();
	if(read == 0){
		e.setCallbackHandler(setPrivateMessageRead);
	    e.setErrorHandler(ajaxErrorHandler);
	    e.ajxSetPMRead(messageid);
	}
	document.getElementById(&apos;pmReply&apos;).style.display = &quot;none&quot;;
	document.getElementById(&apos;pmDetails&apos;).style.display = &quot;inline&quot;;
	document.getElementById(&apos;pmDetails_Subject&apos;).innerHTML=subject;
	document.getElementById(&apos;pmDetails_From&apos;).innerHTML=from;
	document.getElementById(&apos;pmDetails_Message&apos;).innerHTML=message;
}
var setPrivateMessageRead = function(res){
	alert(&apos;set to read&apos;);
}
var ajaxErrorHandler = function(statusCode, statusMsg){
	alert(&apos;Status: &apos; + statusCode + &apos;, &apos; + statusMsg);
}
&lt;/script&gt;
&lt;/code&gt;
The cfc attribute is dot notation to the location of your coldboxproxy.cfc, mine here is at the root. Basically I&apos;m showing the private message details in a div but needing to set the read flag in the database to 1 to indicate it has been read. And using Ajax I can set this in the database for each message read without a page refresh. The alerts in the javascript are for demonstration and testing purposes.

The code I provided is a cut down version of actual code and does not include the view event, form code, queries, or other behind the scenes code. I hope this helps to give you a step ahead on how to use Ajax with the Coldbox framework.
				
				</description>
				
				<category>JavaScript/Ajax</category>
				
				<category>Frameworks</category>
				
				<category>ColdSpring</category>
				
				<category>ColdFusion</category>
				
				<category>Coldbox 2.6</category>
				
				<pubDate>Thu, 16 Oct 2008 08:19:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2008/10/16/Coldbox-Framework-and-Ajax-cfajaxproxy</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Create Coldbox plugin example</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2008/6/6/Create-Coldbox-plugin-example</link>
				<description>
				
				Coldbox plugins are a really useful aspect of the framework when you want to create reusable interfunctions. Interfunction is a term for a function within an application that can be used in any application within any one specific framework.

Coldbox plugin interfunctions are, to me, like UDFs, almost. Except that they are OO capable components. But enough with talk, read more about plugins &lt;a href=&quot;http://ortus.svnrepository.com/coldbox/trac.cgi/wiki/cbMyFirstPlugin&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.

And here&apos;s an example of a custom plugin I created called &quot;MyUtilities&quot; that has a function utilizing CF8&apos;s new image resizing abilities. It&apos;s not expanded yet as this is just what I needed for the moment on a project.

This goes into a cfc (MyUtilities.cfc) file in your plugins directory, I called this plugin &quot;MyUtilities&quot; for now:
&lt;code&gt;&lt;cfcomponent name=&quot;MyUtilities&quot;
       		 hint=&quot;This is a Utilities CFC&quot;
       		 extends=&quot;coldbox.system.plugin&quot;
       		 output=&quot;false&quot;
       		 cache=&quot;true&quot;
       		 cachetimeout=&quot;5&quot;&gt;
			
	&lt;cffunction name=&quot;resizeImage&quot; access=&quot;public&quot; returntype=&quot;Any&quot;&gt;
		&lt;cfargument name=&quot;fileLocation&quot; type=&quot;String&quot; required=&quot;true&quot;/&gt;
		&lt;cfargument name=&quot;destination&quot; type=&quot;String&quot; required=&quot;false&quot; default=&quot;#arguments.fileLocation#&quot;&gt;
		&lt;cfargument name=&quot;xWidth&quot; type=&quot;String&quot; required=&quot;false&quot; default=&quot;100&quot;/&gt;
		&lt;cfargument name=&quot;yHeight&quot; type=&quot;String&quot; required=&quot;false&quot; default=&quot;100&quot;/&gt;
		&lt;cfscript&gt;
			if(IsImageFile(&quot;#arguments.fileLocation#&quot;)){
				myImage		= ImageNew(arguments.fileLocation);
				ImageSetAntialiasing(myImage,&quot;on&quot;);
				ImageScaleToFit(myImage,arguments.xWidth,arguments.yHeight,&quot;highestQuality&quot;);
				ImageWrite(myImage,arguments.destination,1);
				return ImageInfo(myImage);
			}else{
				return false;
			}
		&lt;/cfscript&gt;
	&lt;/cffunction&gt;
	
&lt;/cfcomponent&gt;&lt;/code&gt;

And this is how you&apos;d use it in your code:
&lt;code&gt;imageThumb = getPlugin(&quot;MyUtilities&quot;,true).resizeImage(fileLocation,thumbLocation,width,height);&lt;/code&gt;

You can see from the resizeImage function that I hard coded resize quality and antialiasing, as that is true anywhere in my project for all image sizing. But you can take this and customize it further for your needs. I just mostly wanted to share with you an example of using a custom Coldbox plugin.
				
				</description>
				
				<category>Coldbox 2.6</category>
				
				<category>Frameworks</category>
				
				<pubDate>Fri, 06 Jun 2008 06:13:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2008/6/6/Create-Coldbox-plugin-example</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Coldbox beanfactory populatebean method</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2008/6/4/Coldbox-beanfactory-populatebean-method</link>
				<description>
				
				I have to say I love this automatic bean population thing going around. Model-Glue does it also but since I mostly use Coldbox, that&apos;s what I&apos;m showing here.

WTF, you may ask? Well, you know how when you submit a form to edit a user account for example, and then you have to pass all those form elements to your user bean object&apos;s getters and setters one by one. userObj.setUsername(form.username), userObj.setUserpassword(form.password) and so on.. well you can forget about ever doing this again.

HOW!?!? By using the Coldbox beanfactory populatebean method. You can play with form elements first if you need to, then simply call the populate method passing in the current userbean, and then Coldbox will match form elements to the bean&apos;s getter and do the heaving lifting for you returning an updated bean ready for saving.

2 simple lines, get bean and populate bean. Then do whatever else you prefer from there to save it wherever etc..

&lt;code&gt;&lt;cffunction name=&quot;doEditAccount&quot; access=&quot;public&quot; returntype=&quot;void&quot; output=&quot;false&quot;&gt;
		&lt;cfargument name=&quot;Event&quot; type=&quot;coldbox.system.beans.requestContext&quot;&gt;
		&lt;!--- Logic ---&gt;
		&lt;cfscript&gt;
			userBean = getPlugin(&quot;sessionstorage&quot;).getVar(&quot;User&quot;);
			getPlugin(&quot;beanFactory&quot;).populateBean(userBean);
			getUsersService().saveUser(userBean);
			getPlugin(&quot;sessionstorage&quot;).setVar(&quot;User&quot;,userBean);
		&lt;/cfscript&gt;
		&lt;!--- Display ---&gt;
		&lt;cfset setNextEvent(&quot;myaccount.general.dspAccountHome&quot;)&gt;
	&lt;/cffunction&gt;&lt;/code&gt;

The most important thing to remember is that your actual bean cfc object must use an init method with setters. And the form element names should be the same as the bean names.

A bean&apos;s init:
&lt;code&gt;&lt;cffunction name=&quot;init&quot; returntype=&quot;User&quot;&gt;
&lt;cfargument name=&quot;username&quot;&gt;
&lt;cfset setUsername(arguments.username)&gt;
&lt;/cffunction&gt;&lt;/code&gt;

So that:
&lt;code&gt;&lt;input type=&quot;text&quot; name=&quot;username&quot;&gt;&lt;/code&gt;
Matches:
&lt;code&gt;&lt;cffunction name=&quot;setUsername&quot;&gt;
&lt;cfargument name=&quot;var&quot;&gt;
&lt;cfset variables.instance.username = arguments.var&gt;
&lt;/cffunction&gt;&lt;/code&gt;

Hope that helps. :)
				
				</description>
				
				<category>Coldbox 2.6</category>
				
				<category>ColdFusion</category>
				
				<category>Frameworks</category>
				
				<category>OOP/Patterns</category>
				
				<pubDate>Wed, 04 Jun 2008 19:20:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2008/6/4/Coldbox-beanfactory-populatebean-method</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>ColdSpring ColdboxFactory: DSN and Mail settings</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2008/5/26/ColdSpring-ColdboxFactory-DSN-and-Mail-settings</link>
				<description>
				
				My second day into figuring out Coldbox, here&apos;s a little something cool. Putting it simply, using ColdSpring, in the CS.xml you can define a &apos;coldboxFactory&apos; bean to use in creating other beans that define this factory&apos;s methods as beans also, then pass that bean into a class bean&apos;s property as a bean reference.

Actually, that doesn&apos;t sound simple as it is, so here&apos;s an example. Remember that I&apos;m a newbie, so be nice.

coldbox.xml.cfm
&lt;code&gt;
&lt;MailServerSettings&gt;
	&lt;MailServer&gt;mail.urserver.com&lt;/MailServer&gt;
	&lt;MailPort&gt;25&lt;/MailPort&gt;
	&lt;MailUsername&gt;username&lt;/MailUsername&gt;
	&lt;MailPassword&gt;password&lt;/MailPassword&gt;
&lt;/MailServerSettings&gt;

&lt;Datasources&gt;
	&lt;Datasource alias=&quot;DSNAlias&quot; name=&quot;dsnName&quot; dbtype=&quot;mysql&quot; username=&quot;name&quot; password=&quot;pass&quot; /&gt;
&lt;/Datasources&gt;
&lt;/code&gt;I&apos;ve set mail settings and data source settings here in the main Coldbox config. I&apos;ll be using Coldspring for IoC and so I&apos;ll need to be able to pass this around in my beans.

Coldspring.xml
&lt;code&gt;
&lt;beans&gt;
	&lt;bean id=&quot;coldboxFactory&quot; class=&quot;coldbox.system.extras.ColdboxFactory&quot; /&gt;
	&lt;bean id=&quot;ConfigBean&quot; factory-bean=&quot;ColdboxFactory&quot; factory-method=&quot;getConfigBean&quot; /&gt;
	
	&lt;bean id=&quot;dsnBean&quot; factory-bean=&quot;ColdboxFactory&quot; factory-method=&quot;getDatasource&quot;&gt;
	   &lt;constructor-arg name=&quot;alias&quot;&gt;
	       &lt;value&gt;DSNAlias&lt;/value&gt;
	   &lt;/constructor-arg&gt;
	&lt;/bean&gt;
			
	&lt;bean id=&quot;cfctest&quot; class=&quot;handlers.cfctest&quot;&gt;
		&lt;property name=&quot;dsnBean&quot;&gt;
			&lt;ref bean=&quot;dsnBean&quot; /&gt;
        &lt;/property&gt;
		&lt;property name=&quot;ConfigBean&quot;&gt;
			&lt;ref bean=&quot;ConfigBean&quot; /&gt;
        &lt;/property&gt;
	&lt;/bean&gt;
&lt;/beans&gt;
&lt;/code&gt;This coldboxFactory has several methods that interface with the coldbox config file, among other things I&apos;m sure. Check out the &lt;a href=&quot;http://www.coldboxframework.com/api/&quot; target=&quot;_blank&quot;&gt;API&lt;/a&gt; for more info. But basically I create the coldboxFactory bean, then create other beans of the factory&apos;s methods. Then notice how I pass those beans into the handler beans by reference. These &apos;properties&apos;, as it turns out, are setters in the cfc, such as setDsnBean and setConfigBean. Then I just put them in variables for my other methods.

cfctest.cfc
&lt;code&gt;
&lt;cfcomponent output=&quot;false&quot;&gt;
	&lt;cffunction name=&quot;setDSNBean&quot; access=&quot;public&quot; returntype=&quot;void&quot;&gt;
		&lt;cfargument name=&quot;DSNBean&quot; type=&quot;Any&quot; required=&quot;true&quot;/&gt;
		&lt;cfset variables.dsn = arguments.DSNBean.getName()&gt;
	&lt;/cffunction&gt;
	
	&lt;cffunction name=&quot;setConfigBean&quot; access=&quot;public&quot; returntype=&quot;void&quot;&gt;
		&lt;cfargument name=&quot;configBean&quot; type=&quot;Any&quot; required=&quot;true&quot;/&gt;
		&lt;cfset variables.mailName = arguments.configBean.getKey(&quot;mailUsername&quot;)&gt;
	&lt;/cffunction&gt;
	
	&lt;cffunction name=&quot;capitalize&quot; access=&quot;public&quot; returntype=&quot;string&quot;&gt;
		&lt;cfargument name=&quot;string&quot; type=&quot;string&quot; required=&quot;true&quot;/&gt;
		&lt;cfreturn Ucase(variables.mailName &amp; &quot; - &quot; &amp; arguments.string)/&gt;
	&lt;/cffunction&gt;
&lt;/cfcomponent&gt;
&lt;/code&gt;Don&apos;t dis my cfc, I&apos;m just playing around and testing stuff. Notice the setters that I mentioned before. If you do a dump/abort on these at run time you&apos;ll see what use they are.

general.cfc
&lt;code&gt;
&lt;cffunction name=&quot;index&quot; access=&quot;public&quot; returntype=&quot;void&quot; output=&quot;false&quot;&gt;
	&lt;cfargument name=&quot;Event&quot; type=&quot;coldbox.system.beans.requestContext&quot;&gt;
	
	&lt;!--- Logic ---&gt;
	&lt;cfset string = &quot;Welcome!&quot;&gt;
	&lt;cfset string = variables.ioc.getBean(&quot;cfctest&quot;).capitalize(string)&gt;
	&lt;cfset Event.setValue(&quot;welcomeMessage&quot;,string)&gt;	
	
	&lt;!--- Display ---&gt;
	&lt;cfset Event.setView(&quot;home&quot;)&gt;
&lt;/cffunction&gt;
&lt;/code&gt;And finally here&apos;s the handler that uses the IoC plugin I set in variables in the handler&apos;s init function that gets the bean set in Coldspring and runs the method that utilizes all the stuff we just went through. Check out &lt;a href=&quot;http://ortus.svnrepository.com/coldbox/trac.cgi/wiki/cbColdspringGuide&quot; target=&quot;_blank&quot;&gt;Coldbox&apos;s Coldspring documentation&lt;/a&gt; for more information.

There are other factories to use I&apos;m guessing and other factory methods within those. You can use all the methods in the coldbox.system.controller as beans also. But like I said, I&apos;m just discovering this stuff right now. Frankly I need to think over wether or not passing bean reference properties to all my CS beans is the most effective way of using global configs any ways. Seems rather repetative as apposed to putting such things in a request scope through onRequestStart or something.
				
				</description>
				
				<category>Frameworks</category>
				
				<category>ColdSpring</category>
				
				<category>ColdFusion</category>
				
				<category>Coldbox 2.6</category>
				
				<pubDate>Mon, 26 May 2008 06:06:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2008/5/26/ColdSpring-ColdboxFactory-DSN-and-Mail-settings</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>ini files with multiple sites - getProfileString</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2007/9/29/ini-files-with-multiple-sites--getProfileString</link>
				<description>
				
				Its common now days to use an ini config file to set specific params for your site or application. An ini file is a plain file ending in an ini extension. You set params in a variable=value manner line by line, sometimes heading different sections with bracket enclosed headings (notice no space around =&apos;s below):

example ini file (www.cfcdeveloper.com.ini)
&lt;code&gt;
[settings]
dsn=myDSN
mailserver=mymail.mailserver.com
mailusername=username
mailpassword=password
[other]
url=http://www.myurl.com
adminemail=myemail@myurl.com
&lt;/code&gt;

Another good use for an ini file could be to duplicate an application or site across multiple domains and owners depending on the URL domain name, basically hosted on the same server. That way you can sell use of an application or site and maintain central control over the big picture. An update or new enhancement would populate all domains at once instead of having to duplicate the changes numerous times.

One way to do this is to name your ini file (this could be applied to CSS also) the same as the domain in which it is meant for. So I would name an ini file for my site www.cfcdeveloper.com.ini. Then if joebob.com wanted to use my site also, I could sell him the use of it and simply make another ini file named www.joebob.com.ini. Then when a visitor hits joebob&apos;s site, it will use his ini file instead of mine.

Something like this:&lt;br&gt;
&amp;lt;cfset var iniFile=&quot;#getDirectoryFromPath(GetCurrentTemplatePath())#/#cgi.server_name#.ini&quot;&amp;gt;

So now the magic begins. We need to put these variables into a site wide scope to use everywhere. You can decide if you want to use application or request scope or something else. I like to use the request scope myself for smaller applications, application scope for specific other purposes and very large applications.

And here is the most simplified manner which I can show you how to do it (using the ini file above for example):
&lt;code&gt;
&lt;cfset var iniFile=&quot;#getDirectoryFromPath(GetCurrentTemplatePath())#/#cgi.server_name#.ini&quot;&gt;

&lt;cfset sectionname = &quot;settings&quot;&gt;
&lt;cfset request.settings.dsn = getProfileString(iniFile,sectionname,&quot;dsn&quot;)&gt;
&lt;cfset request.settings.mailserver = getProfileString(iniFile,sectionname,&quot;mailserver&quot;)&gt;
&lt;cfset request.settings.mailusername = getProfileString(iniFile,sectionname,&quot;mailusername&quot;)&gt;
&lt;cfset request.settings.mailpassword = getProfileString(iniFile,sectionname,&quot;mailpassword&quot;)&gt;

&lt;cfset sectionname = &quot;other&quot;&gt;
&lt;cfset request.settings.url = getProfileString(iniFile,sectionname,&quot;url&quot;)&gt;
&lt;cfset request.settings.adminemail = getProfileString(iniFile,sectionname,&quot;adminemail&quot;)&gt;
&lt;/code&gt;

Hopefully that is all self explainatory above. Of course there are more efficient means to accomplish this also including using the getProfileSection function to fetch the sections and parse those out automatically. Look in the documentation to find the way you prefer. 

You can also use the setProfileString function to set values to ini variables if empty or other conditions. Or maybe set a default ini and use Application.cfc to set ini variables depending on the URL and such. There are many ways to use this power.

One other thing I want to show you about using ini files for sharing an application with many domains on one server. You can also make one ini file and give the sections names for the domain calling it. That domain would set variables depending on the section instead of the file name. Let me try to show you.

example (site.ini):
&lt;code&gt;
[cfcdeveloper]
sitename=cfcDeveloper
url=www.cfcdeveloper.com
dsn=cfcdsn
[joebob]
sitename=JoeBob
url=www.joebob.com
dsn=joedsn
&lt;/code&gt;

Then you set the ini section before calling the ini to set variables to a site wide scope:&lt;br&gt;
&amp;lt;cfset request.iniSection = &quot;cfcdeveloper&quot;&amp;gt;

Something like this:
&lt;code&gt;
&lt;cfset var iniFile=&quot;#getDirectoryFromPath(GetCurrentTemplatePath())#/site.ini&quot;&gt;

&lt;cfset sectionname = request.iniSection&gt;
&lt;cfset request.settings.sitename = getProfileString(iniFile,sectionname,&quot;sitename&quot;)&gt;
&lt;cfset request.settings.url = getProfileString(iniFile,sectionname,&quot;url&quot;)&gt;
&lt;cfset request.settings.dsn = getProfileString(iniFile,sectionname,&quot;dsn&quot;)&gt;
&lt;/code&gt;

There are pros and cons to any style. Using sections for sites or domains, you have to add a new variable to all the sections one by one. But at least its in the same file. Using a file per domain, you have to open each one and add a new variable when one is added to the application. Pick whichever means suits you best.
				
				</description>
				
				<category>ColdFusion</category>
				
				<category>Frameworks</category>
				
				<pubDate>Sat, 29 Sep 2007 03:53:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2007/9/29/ini-files-with-multiple-sites--getProfileString</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Architectural Framework Woes</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2007/8/16/Architectural-Framework-Woes</link>
				<description>
				
				AHHHHHHHH! @#!$%#&amp;%@!

Yeah, I&apos;m a little aggravated this morning. I&apos;m coding. It&apos;s not that I don&apos;t see the value of using MVC or any other type of framework, I hate to love them. A framework or any organized architecture, be it OO or whatever, is only as good or useful as the programmer who who knows it or uses it. Otherwise, its a nightmare to step into and have to debug or enhance if you&apos;ve never been in it before. Its quit a learning curve that adds time to the whole process.

There are many frameworks and architectures out there now. Knowing as many as possible helps you to learn each one much faster. Then you pretty much become an architect developer or framework developer.

As my thoughts ramble on here I&apos;m wondering if we programmers are creating such intricate and complexed patterns of doing something fairly simple is so that we can mask our work in a way that you must be skilled to read it and do it in any manner. Surely anyone can do spaghetti code, but break out the OO and the MVC and you&apos;ve got a recipe for a lucrative highly skilled professional career. Books will and have been written about these ways of coding and now we can teach them in classes and give certifications in them.

Anyways, so I&apos;m debuging an application this morning that I&apos;ve never seen before. The application was developed in a framework I&apos;ve never seen before either. I know many frameworks such as Fusebox, MachII, and Model-Glue, but this was different and proprietary. An error was being thrown that was not displaying the correct message and I needed to find the mechanism that handled the error and everything else. Without getting technical, I&apos;m looking in 5 different files tracing back the entire path of the whole mechanism and getting frustrated. I&apos;m sure I could come up with a much more shallow mess of code to do the same thing.

But here I am looking in controllers, facades, managers, components, config files, and everything else. It&apos;s worse than a maze, its more like a death maze. The further you get in, the harder it is to find the end, and theres no way out. At every turn you must remember all the steps you took up to now and all the steps you didn&apos;t take, as well as a riddle you read at every dead end, all without any way to write it down.

Ok, breath deep and relax. Is it too complicated? I don&apos;t mean is it too complicated for me to do. Of course I&apos;ll do my job and do it well. In fact, I really enjoy the challange and reward. But can we all get together and agree on something standard, for the sake of my sanity. Structural engineers build buildings and bridges with only a few differences between them. What works, works, and it keeps the structures from falling.

But this is all just wishful thinking from a crazed coder in a moment of despair. Non-programmers who think our job is easy would go mad to step inside our mind. The diversity of ways a coder can program is what drives technology to new heights and discoveries. I understand the nature of the beast and the importance of its complexity, I really do. Maybe more vacation time is the answer?
				
				</description>
				
				<category>Frameworks</category>
				
				<category>OOP/Patterns</category>
				
				<category>Personal</category>
				
				<pubDate>Thu, 16 Aug 2007 06:24:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2007/8/16/Architectural-Framework-Woes</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Creating an MVC ColdFusion OOP Application - Part 3</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2007/3/30/Creating-an-MVC-ColdFusion-OOP-Application--Part-3</link>
				<description>
				
				Part &lt;a href=&quot;http://www.cfcdeveloper.com/index.cfm/2007/3/29/Creating-an-MVC-ColdFusion-OOP-Application--Part-2&quot;&gt;2&lt;/a&gt;

Welcome to part 3, setting up the ColdFusion Server and MySQL database on your Windows PC, also called setting up your development environment. I&apos;m hesitant about including this in my series because it has been discussed and taught just about everywhere. But mostly where I see a tutorial, each time it&apos;s a little different. So I thought it would be best to tell and show you how I set my development server up just in case your following along and suddenly something doesn&apos;t work right, you come here and see if the problem might be server related, maybe some step in the set up you did different than me. Unfortunately however, not all PC&apos;s are the same and there is the off chance that someone will have problems beyond my ability to help. There&apos;s one part in particular with my set up that took me 3 days to troubleshoot to get it working, luckily I wrote about it in my blog some time back, so now it&apos;s just part of the process. Hey, no one said programming was easy, it takes patience and determination.

While we&apos;re on the subject of setting up the development environment let&apos;s discuss some other tools you&apos;ll need if you don&apos;t have them already. Pick these up after setting up your development environment. This includes an IDE (integrated development environment) such as &lt;a href=http://www.adobe.com/products/dreamweaver/ target=_blank&gt;Dreamweaver&lt;/a&gt; like I use or anything else you can write and save files with, even Notepad. If you can&apos;t get Dreamweaver I suggest &lt;a href=http://www.eclipse.org/ target=_blank&gt;Eclipse&lt;/a&gt; with the &lt;a href=http://www.eclipseplugincentral.com/Web_Links-index-req-viewlink-cid-175.html target=_blank&gt;CFEclipse&lt;/a&gt; ColdFusion plugin, it&apos;s free and very powerful. There&apos;s even an &lt;a href=http://www.eclipseplugincentral.com/Web_Links-index-req-viewlink-cid-684.html target=_blank&gt;Eclipse SQL Explorer&lt;/a&gt; plugin, which I haven&apos;t tried but you might need later also.

Speaking of an SQL explorer, you&apos;ll need an interface to your MySQL data server when it&apos;s set up so you can actually create and manage databases and tables. If you&apos;d rather use MSSQL data server instead of MySQL, please do so, but I&apos;m not telling about that here. I use MSSQL at work with the MSSQL Management Studio and love it. For MySQL however, I love using Premiumsoft&apos;s &lt;a href=http://www.navicat.com/ target=_blank&gt;Navicat&lt;/a&gt; tool, which I paid about $100 for. But if you want something for free, use phpMyAdmin, which we will be installing anyways, so just hang on.

Ok, so lets get busy installing something. First lets get ColdFusion installed. ColdFusion comes free as a developer edition which is full featured. The only thing different from the $X,000 version is that the free version only allows about 10 or so connections per server. Download the free ColdFusion MX 7 developer edition from &lt;a href=http://www.adobe.com/products/coldfusion/ target=_blank&gt;here&lt;/a&gt;. You&apos;ll need to sign up for a membership to get a username and password. The download is 281 MB, luckily I have an 8Mbps cable connection and it only take me about 45 seconds to download.

Now, double click the installer and follow the directions, this part will take about 10-15 minutes total. Use the defaults everywhere but choose the J2EE configuration (ColdFusion with JRUN 4) in step 4 and choose Built in web server in step 7. Here&apos;s a good place to see screenshots of the installation and the steps: http://www.quackit.com/coldfusion/tutorial/coldfusion_mx_installation_guide.cfm

At the end of the installation you&apos;ll have a new directory under your C drive named JRun4. Your web sites will go under the C:/JRun4/servers/ directory which we will create when we get to that point. You should also be able to browse to the default installed web site at http://localhost:8300/ in your browser. Which will show nothing except two folders to your docs and CFIDE, more on that later. For now, just check that these two things are true or else uninstall and start over till you get it right.

Now lets get your MySQL data server installed, which happens to be easier than ColdFusion installation. We will be using a 4 in 1 application installer that will also be installing an Apache web server, MySQL data server, and the PHP server parser. With this installation you be able to do two things, develop PHP web sites if you want, and use the phpMyAdmin to manage your data server if you need it. If however you don&apos;t want all that and will be using another SQL manager, you could just go to the MySQL web site to download and install their single free product. The 4 in 1 installer is also free, called a WAMP, the best one that I use is &lt;a href= target=_blank&gt;here&lt;/a&gt;, it&apos;s only about 17 MB. Download then double click to install. The installer is extremely easy and fast, even a 5 year old could do it, so I&apos;ll just leave this to you. Once complete you will be able to browse to http://localhost/ where you&apos;ll see the WAMP welcome page and some links. One of the links is to the phpMyAdmin tool. The phpMyAdmin may need some config work to get working, if so just ask and I&apos;ll comment back the help you need.

By the way, http://localhost/ and http://localhost:8300/ is completely different. With the Apache server install you basically have two separate servers now. One is an Apache PHP server and the other is a J2EE ColdFusion server. Notice we didn&apos;t use Windows IIS server at all, don&apos;t use it.

Now you have the ColdFusion developer server up and the MySQL server up and we&apos;ll be using these two together to create powerful apps. Just leave it at that for now and we&apos;ll configure the rest when we&apos;re ready to set up our web app. Then I&apos;ll tell you a little more about the ColdFusion server and Jrun and show you about creating instances and why.

Oh, almost forgot about another important tool. The image editor. I use &lt;a href=http://www.adobe.com/products/fireworks/ target=_blank&gt;Fireworks&lt;/a&gt; for layout and gif creations. Then I&apos;ll use &lt;a href=http://www.adobe.com/products/photoshop/family/ target=_blank&gt;Photoshop&lt;/a&gt; for complexed jpg photos and then I might use &lt;a href=http://www.adobe.com/products/illustrator/ target=_blank&gt;Illustrator&lt;/a&gt; for logos and some illustrations. It&apos;s controversial as to which is best for what purposes and why, but I always say that the tool is only as good as the person using it, so decide for yourself which you like and want to use for whatever purpose. If your good at one of them and feel good using it, then use it. As for free image editors, there aren&apos;t very many good ones if any at all. I&apos;ve never used a free one before but I hear that &lt;a href=http://www.gimp.org/ target=_blank&gt;Gimp&lt;/a&gt; is good, but I&apos;ve never used it.

So go get some tools, play around with them and I&apos;ll see you in the next part of this series where we&apos;ll talk about gathering requirements for our application. This would be the part where you meet with the client or your boss and discuss the project in detail.
				
				</description>
				
				<category>OOP/Patterns</category>
				
				<category>Frameworks</category>
				
				<category>ColdFusion</category>
				
				<pubDate>Fri, 30 Mar 2007 21:08:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2007/3/30/Creating-an-MVC-ColdFusion-OOP-Application--Part-3</guid>
				
			</item>
			
		 	
			</channel></rss>
	

