| By Michael Givens | Article Rating: |
|
| August 15, 2007 12:30 PM EDT | Reads: |
9,619 |
Whether it's in factories or workshops, in mines or forests, in offices or homes, or even in our sacred ColdFusion Administrator, anything that impairs the efficiency of workers is always worthy of improvements in the process or changing the way of doing things.
Levering ColdFusion ServiceFactory to get work done is one example. Figure 1 is a screenshot of an example Flex-ColdFusion hybrid application that allows manipulation of ColdFusion mapping without having (or even needing) access to the ColdFusion Administrator.
Look at the code. The Flex UI code is shown in Listing 1. The initialize attribute in the main MXML file calls the getIP() function during initialization of the Flex application. This function triggers a RemoteObject invocation of the roMapping.getVisitorIP() method. The getVisitorIP() method is the first function shown in Listing 2. ( Listing 2 can be downloaded from the online version of this article at http://coldfusion.sys-con.com.) By examining the IP address of the user, we can programmatically allow Flex to decide if the CFC mapping utility is visible. This is a way to limit CFC mapping changes to users on your internal network. For instance, in the Flex code, the getVisitorIP_handler has a conditional that ensures that only IP addresses on an internal network that start with 192.168 can call the RemoteObject's method, roMapping.getMappings(). Of course, you can change that to whatever your internal network's IP addresses start with once you download the code. Speaking of the code, the full source code is available at http://labs.insideflex.com/flextraining/cfmapping/bin/srcview/index.html.
Provided the user is coming from the appropriate IP address, the RemoteObject method, roMapping.getMappings(), instantiates a factory object and calls the ColdFusion servers ServiceFactory getMappings method:
<cfset factory=createObject("java","coldfusion.server.ServiceFactory")>
<cfset mappings = factory.runtimeService.getMappings()>
A structure of arrays stores the mapping information returned from the ServiceFactory and is returned to the Flex UI as a structure:
<cfset stMapping = structNew()>
<cfset aLogicalPath = ArrayNew(1)>
<cfset aDirectoryPath = ArrayNew(1)>
<cfloop collection="#mappings#" item="thismapping">
<cfscript>
ArrayAppend(aLogicalPath, thismapping);
ArrayAppend(aDirectoryPath, mappings[thismapping]);
</cfscript>
</cfloop>
<cfscript>
StructInsert(stMapping, "logicalpath", aLogicalPath);
StructInsert(stMapping, "directorypath", aDirectoryPath);
</cfscript>
<cfreturn stMapping/>
Methods for creating, updating, and deleting mappings are also included in the CFC.
Warning
Updating or deleting ColdFusion mappings should be done with caution, especially on shared ColdFusion servers.
Flex Form validation is used and shown in Figure 2 and Figure 3.
For additional information, my Flex Cookbook post, "Get a Client IP Address with a RemoteObject Call," demonstrates limiting access to Flex content on your internal network or by selected IP addresses. It uses the ColdFusion CFML CGI.Remote_Addr variable passed to the Flex UI via AMF. www.adobe.com/cfusion/communityengine/index.cfm?
event=showdetails&postId=3462&productId=2
.
I hope you found this article useful. If you have any follow-up questions, feel free to contact me.
Published August 15, 2007 Reads 9,619
Copyright © 2007 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Michael Givens
Mike Givens is the CTO of U Saw It Enterprises, a Web technology consulting firm based in Marietta, GA. He is an Adobe Corporate Champion known to share his experience and evangelism of all things Adobe. Certified in both ColdFusion 5 and as an Advanced CFMX Developer, he has been using ColdFusion since the days of Allaire Spectra. For the last 11 years, he has been seen with his head down - deep in the code.
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Adobe Unveils LiveCycle Enterprise Suite 2 for Deployment in the Cloud
- Adobe Flex Developer Earns $100K in New York City
- Adobe May Cooperate with Apple to Transplant Flash Player to iPhone
- Ph.D. in Twitter Anyone?
- Eolas Sues the Internet
- Adobe LiveCycle Enterprise Suite 2 for Cloud Computing
- Adobe Betas Target RIAs and Cloud Computing
- Special Report on the Emerging Cloud Computing Trend
- Adobe Cans Another 9% of its Workforce
- My Thoughts on Ulitzer
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Ulitzer Live! New Media Conference & Expo
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Eval JavaScript in a Global Context
- Fig Leaf Software to Exhibit at Government IT Conference & Expo
- Cloud Executives Feature on Cloud Computing Expo Power Panel
- Software Flexibility in the Cloud - Part 4 of 5
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Is Microsoft as Free as Open Source?
- Adobe Reader Sued
- Adobe Unveils LiveCycle Enterprise Suite 2 for Deployment in the Cloud
- Where Are RIA Technologies Headed in 2008?
- Cover Story: How to Increase the Frame Rates of Your Flash Movies
- AJAX World RIA Conference & Expo Kicks Off in New York City
- Your First Adobe Flex Application with a ColdFusion Backend
- Adobe Flex 2: Advanced DataGrid
- i-Technology Blog: Death-Knell For "Rich Media? Hardly!
- Adobe/Macromedia - Microsoft, Look Out!
- How To Create a Photo Slide Show ...
- Adobe Flex Interface Customization - Themes, Styles, Skins
- Personal Branding Checklist
- Has the Technology Bounceback Begun?
- "Real-World Flex" by Adobe's Christophe Coenraets



































