 |
Thoughts, ideas, tips, musings, and pontifications (not necessarily in that order) by Ben Forta ...
NOTE: This is my personal blog, and the opinions and statements voiced here are my own.
January 30, 2004
This one is apparently not that new, but it was just brought to my attention, and I thought it worth sharing in case others had not run into it yet. Rohan Clan has created a basic ColdFusion Eclipse plug-in for use with Eclipse 2.1 and 3 (and apparently tested on Windows, Mac, and Linux running JRE 1.4). Details at http://www.rohanclan.com/index.cfm?mode=product&product=cfeclipse/index.
January 29, 2004
I just arrived back in the US, and am now online for the first time in over a day (staring in horror at my rapidly enlarging inbox). Last night I presented a Flex Sneak Peek to a combined CFUG/MMUG in London. The room was full, but we started late because of snowfall that almost brought London to a grinding halt (I'm going to have send some Michigan snow over their way, the overreaction to less than an inch of snow bordered on comical).
I demonstrated a sophisticated shopping-cart application created by Christophe Coenraets, an impressive app, and one that all assumed would be really difficult to create. And then I walked through building a ColdFusion powered Flex application, starting with a simple SOAP call, then displaying the data in a grid, then working with formatting, adding edit fields, binding the elements together, adding boxes and tabs for better control, and then some MXML embedded within a .cfm page. Once done we looked at the shopping-cart code to see that it was really not much more complex that what we had built interactively. The crowd was visibly impressed, I asked "how many of you can see yourself building applications this way", and just about every hand in the room went up.
The biggest hassle was the number of questions that I could not answer (including price, release dates, and packaging issues, all of which were asked repeatedly in various forms). But, despite that, the response was incredible, and the event a major success.
Pictures of the event have been posted at http://www.mmug.co.uk/index.cfm?objectid=6261A8FD-50DA-4D01-8798C287139113DB.
January 27, 2004
Posted At : 3:37 AM
Related Categories:
Stuff
I am on the road again, somewhere between Edinburgh and London. I have no network connection (wired or wireless), and it looks like my modem is dead (this is the first time I have tried the modem since my laptop was repaired, I should have tested it before I left).
So how am I posting this? Via a GPRS network connection. GPRS (General Packet Radio Service) is a non-voice service that provides connections to Internet services. GPRS is primarily used for Internet access on devices (like cell phones), but some devices allow GPRS connections to be shared. To use GPRS you need a device that supports it (most newer GSM handhelds provide GRPS support), and of course your telco must offer the service. So, my laptop talks to my cell phone via Bluetooth, and the cell phone connects via GPRS to provide network access, making my cell phone essentially a wireless modem as far as the laptop is concerned. The throughout is miserable (over 100K in theory, slower than a dial-up in practice) but it works, and it will improve when next generation services are rolled out.
For now, being in the middle of nowhere and able to easily get online, well, it's a bit of a thrill. Truly, there is something to be said for standards.
January 24, 2004
was introduced to ColdFusion in version 5, but apparently there are many CFers who have yet to discover this invaluable tag. In the past week I received three different code help e-mail requests, all of which I answered with suggestions, all of which included the use of in test code, and all of which were met with responses to the effect of "huh, I've never used before.
So, is an all-purpose data display tool. Give it a simple variable and it'll display it. But can do more than just display simple variables, it can render entire queries, arrays, structures, XML document objects, instantiated ColdFusion Components, Java objects, and any combination of the above (an array of structures containing an array of queries, for example). You can even entire scopes (like SESSION, or VARIABLES) because those are actually structures.
In other words, can display most of what standard debug output can, and a whole lot more too. In fact, come to think of it, I have not used standard debug output in a long time, nowadays I rely mostly on .
If you have yet to use this remarkable tag, do so, quickly. But one point to keep in mind, expects expressions, not names of variables. So, if you the word VARIABLES will be displayed, to dump all variables you'd need .
January 21, 2004
Posted At : 4:20 PM
Related Categories:
Flex
I am working on an application that requires users to select from long lists of options. I am not a fan of multiple select list boxes (that whole shift-click ctrl-click thing is a pain). In HTML I usually use lots and lots of checkboxes, but what I'd really like is a list of checkboxes, kind of a list/checkbox hybrid. HTML can't do that, but Flex can. A simple demo of what I mean is at http://www.forta.com:8100/flex/work/testcbl.mxml. The listbox is scrollable, each item has a checkbox, and a counter shows the number of selected items.
Here's the code used in this MXML file: <?xml version= "1.0"?> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" width="200" height="200"> <!-- Test data --> <mx:Model id="data"> <fruit prod_id="1" prod_name="Apple" /> <fruit prod_id="2" prod_name="Grapefruit" /> <fruit prod_id="3" prod_name="Kiwi" /> <fruit prod_id="4" prod_name="Lemon" /> <fruit prod_id="5" prod_name="Lime" /> <fruit prod_id="6" prod_name="Mango" /> <fruit prod_id="7" prod_name="Orange" /> <fruit prod_id="8" prod_name="Pear" /> <fruit prod_id="9" prod_name="Tangerine" /> </mx:Model> <!-- CheckBoxList control --> <CheckBoxList id= "dbCbl" title= "Build your fruit salad:" dataProvider= "{data.fruit}" labelField= "prod_name" heightFlex= "1" widthFlex= "1" /> <!-- Feedback, how many selected? --> <mx:Label id="feedback" text="Selected: {dbCbl.selectedCount}" /> </mx:Application>
Most of the code is simply populating some test data (in a real app this data would likely come from a database or SOAP call or XML feed). The control itself is the CheckBoxList tag which takes a title, a dataProvider (the test data), and the name of the field to use for checkbox labels. The page then uses a mx:Label to display the count, binding the label text to the control's selectedCount property.
But CheckBoxList is not a Flex control. What is it? It is a custom control, one that I just wrote. And the process was incredibly easy. Here is the control code: <?xml version= "1.0" encoding= "iso-8859-1"?> <mx:VBox xmlns:mx="http://www.macromedia.com/2003/mxml" hScrollPolicy="off" vScrollPolicy="off"> <mx:Script> // Properties var title:String; // Control title var dataProvider:Object; // Data provider var labelField:String; // Label field var selectedCount:Number=0; // Total checked var selectedIndices:Array; // Checked indices // Update selectedIndices and selectedCount <![CDATA[ function selectionMade() { // Init vars selectedCount=0; selectedIndices.length=0; // Loop through the checkboxes for (var i=0; i<cb.length; i++) { if (cb[i].selected) { // If checked selectedCount++; selectedIndices.push(i); } } } ]]> </mx:Script> <!-- Title --> <mx:HBox widthFlex="1"> <mx:Label id="lbl" text="{title}" /> </mx:HBox> <!-- Checkboxes --> <mx:VBox borderStyle="inset" widthFlex="1" height="{height - lbl.height}" vScrollPolicy="auto"> <!-- Loop through data --> <mx:Repeater dataProvider="{dataProvider}" id="r"> <!-- Checkbox for each item --> <mx:CheckBox id="cb" label="{r.currentItem[labelField]}" click="selectionMade()" /> </mx:Repeater> </mx:VBox> </mx:VBox>
The control extends VBox (the Flex vertical box control). A script block defines the properties (including selectedCount which is bound in the calling page), and a function named selectionMade() which updates the properties each time a checkbox is checked (or unchecked). Then comes the UI, an HBox is used to display the passed title, a scrollable VBox contains the checkboxes, a Repeater loops through the passed data, and for each item CheckBox defines a checkbox (and fires selectionMade() on each click).
And that is all it takes. File CheckBoxList.mxml is in the same directory and can thus be invoked just by specifying the tag name. The control is not tied to any specific data, and accepts both data and the name of the field to display, and bindings between Flex controls and custom controls just works.
It's a beautiful thing indeed (and now I can get back to building the app that needed the control in the first place).
January 20, 2004
Posted At : 11:50 PM
Related Categories:
Stuff
This is an oldie, but a goodie (I am blogging it partially so that I don't forget the URL again). http://www.skepdic.com/ is "A Collection of Strange Beliefs, Amusing Deceptions, and Dangerous Delusions", over 400 articles in all. I don't necessarily agree with all of Robert Carroll's positions, but this is fun and provocative reading nonetheless.
January 16, 2004
Earlier this week I blogged an example of Flex embedded in ColdFusion. This is a powerful and intuitive way to leverage Flex, but the installation and setup do require some know-how and manual tweaking. So, having gone through the process, and knowing that many of you will want to do the same, I thought I should share the process (just the high-level overview for now).
1: ColdFusion is a Java application, so is Flex (for now). Both ColdFusion and Flex are installed on top of J2EE servers. When ColdFusion MX Enterprise is installed there are three installation types presented as options, the 2nd installs JRun and a ColdFusion instance deployed on top of it, and the 3rd creates a ColdFusion archive (EAR or WAR) for deployment on top of an existing J2EE server. To use Flex with ColdFusion this type of install is required, standalone install (and thus ColdFusion Standard) will not support the deployment of Flex. So, first of all, ColdFusion must be deployed and running on top of a J2EE server.
2: Flex comes with an installer which actually does not really install Flex at all. What it does do is create WAR files for deployment on top of a J2EE server (like JRun). The installer created a folder and deposits several files in it, one of those is named flex.war and it is that file that contains Flex itself and needs to be deployed on the J2EE server. The exact steps to deploy flex.war vary based on the J2EE server being used. There are J2EE management tools that may be used to deploy WAR files, or you may simply expand the war file (using the jar utility) so that it may be detected by the J2EE server.
3: In order to embed Flex MXML (via the Flex JSP Tag Library) in your CFML code, Flex must be deployed in the same server and context as ColdFusion itself. So, if you deployed ColdFusion MX into a context named "cf", Flex will need to deployed into "cf" as well. The simplest way to do this is to manually expand flex.war into the same folder in which ColdFusion itself was expanded.
4: In the application's WEB-INF folder there is a file named web.xml, this file contains application information needed by the J2EE server so as to be able to deploy the application in the folder. ColdFusion installs its own web.xml, and Flex comes with one too. These contents of these two files must be merged (as only one web.xml may exist).
5: Then simply restart the server, and both ColdFusion and Flex will be deployed. You can then create .cfm files, .mxml files, and also embed the Flex JSP Tag Libraries within your CFML code.
NASA JPL (Jet Propulsion Laboratory at the California Institute of Technology in Pasadena) is one of the most popular Web destinations right now. The next time you visit http://www.jpl.nasa.gov/ pay close attention to the URLs, lots of them have a .cfm extension. JPL has been using ColdFusion for a long time, ever since CGI and DBML days. This site appears to be running ColdFusion 5 on Linux. It is not an MX site (yet), but still, it is another great example of ColdFusion powering high profile high volume sites. Thanks to Alex Hubner for pointing this one out to me.
January 15, 2004
My latest CFDJ column, entitled "I Don't Hate Dreamweaver", is now online. You can read it at: http://www.sys-con.com/coldfusion/article.cfm?id=696.
January 13, 2004
I'll be in Edinburgh later this month, and will get the chance to speak to the Scottish CFUG (for the first time) on Monday, January 26th. Topic and specifics have not been announced, so no details yet (although I think I can safely assume that we'll meet for drinks). Details should be posted shortly at http://www.scottishcfug.com/. Hope to see you there.
January 12, 2004
My last Flex blog post demonstrated Flex as a ColdFusion client, a n-tier application using ColdFusion as the logic layer and Flex as the presentation layer. Here is another way to integrate Flex and ColdFusion; dynamically generated Flex.
Click on URL http://www.forta.com:8100/cf/flex/tree.cfm to see an example of a Flex tree. It is a really simple example, and mildly impressive at best. So why am I posting this? Look at the URL, it is a .cfm URL, not a .mxml url.
Christophe Coenraets posted a really useful entry on using the Flex JSP Tag Library so as to be able to generate MXML inline within a JSP page. (See http://www.markme.com/cc/archives/004021.cfm).
Can ColdFusion users do the same? Absolutely, that's exactly what the tree example is doing. ColdFusion can import and invoke JSP tags, and the Flex JSP tags are no exception.
Here is the CFML code used in this example: <!--- Import Flex JSPs ---> <CFIMPORT TAGLIB="/WEB-INF/lib/flex-bootstrap.jar" PREFIX="mm"> <!--- Create tree XML ---> <CFSAVECONTENT VARIABLE="tree"> <node label='Option 1'> <node label='Option 1.1'/> <node label='Option 1.2'/> </node> <node label='Option 2'/> </CFSAVECONTENT> <!--- Page ---> <HTML> <BODY> <H1>Flex Embedded in ColdFusion </H1> <!--- Start of MXML ---> <mm:mxml> <mx:Application width="200" height="200" xmlns:mx="http://www.macromedia.com/2003/mxml"> <!--- Tree ---> <mx:XML id="myTree"> <!--- CF tree data ---> <CFOUTPUT>#tree# </CFOUTPUT> </mx:XML> <mx:Tree widthFlex="1" heightFlex="1" dataProvider="{myTree}"/> </mx:Application> </mm:mxml> </BODY> </HTML>
In this example I hard-coded the menu contents to keep things simple, but you can imagine using queries or CFCs or any CFML code here. This type of integration, being able to use both CFML and MXML together, makes it really easy to create ColdFusion/Flex applications.
Posted At : 12:33 PM
Related Categories:
Stuff
The Salt Lake Tribune is running a story (by a Boston Globe columnist) on corporate bloggers, starting with the tale of a Microsoft employee who was fired for blogging "a photo of a pallet of Apple Macintosh computers being delivered to Microsoft headquarters". The story goes on to suggest that "Perhaps the most blog-friendly company in America is Macromedia, a multimedia software producer based in San Francisco.", and mentions Mike Chambers' blog as an example. Full story at http://www.sltrib.com/2004/Jan/01122004/business/128240.asp.
Posted At : 12:24 PM
Related Categories:
Flash
ZDNet is running a story on the emergence of Flash as an alternative to Windows Media Player, RealNetworks RealPlayer, and Apple's QuickTime. Nothing shockingly new, but useful perspective nonetheless. Story is at http://zdnet.com.com/2100-1107_2-5139102.html.
January 9, 2004
It had to happen, I just ran into the first real glitch in my car's Bluetooth feature - no support for +. All dialing is via voice recognition, you say "dial" to dial, "pair" to pair a phone, "phonebook" to access the phonebook, "one" for 1, and so on. Managing phones and phonebook entries works this way too, in fact there is no way to interact with the system other than via voice recognition. Obviously, all digits are recognized. Non-numeric characters are recognized too, but just "star" for *, and "pound" for #. So why do I need to use +? I have a GSM phone and + is used by GSM to specify a country code, +44 for England, +1 for USA, +61 for Australia, and so on. I just needed to call a Macromedia UK employee and couldn't, "plus" is not recognized! This is a significant oversight, especially considering that most of the Bluetooth enabled phones available in the US are GSM phones. This does not preclude International dialing, but it takes make doing so a pain (there is a workaround, dial on the phone and transfer the call, but that's not ideal). I just discussed this with engineers at Acura who at first did not believe me that I actually needed the +, and finally agreed to "look into this one". Oh well, that's the price you pay for playing with the cutting edge.
January 8, 2004
Posted At : 11:43 AM
Related Categories:
Stuff
I've been buried in DBMS software this past week, and just finished brand new installs of DB2, MySQL, Oracle, PostgreSQL, SQL Server, Sybase on Windows and Linux boxes. (No, I am not a masochist, this was to test SQL scripts on lots of platforms).
Of the six DBMSs listed, all but MySQL and PostgreSQL come with some form of interactive administrative tools (the lack of these tools in MySQL and PostgreSQL is best left for another post). The SQL Server tools are native Windows apps (I am assuming they are written in C/C++), whereas others (Oracle, Sybase) are Java applications. And the latter are appalling; they are slow and sluggish and unintuitive and non-responsive and ... Actually, I got so frustrated with the Oracle Enterprise Manager that I gave up and used command-line SQL to set up user accounts, and to create tables and establish constraints (not a pleasant task), and Oracle is the best and most all encompassing of them! Part of this is a usability issue, and regardless of how you feel about Microsoft, they have mastered the art of creating intuitive usable interfaces (when they want to). But the other part of the problem is Java.
I understand why vendors would choose to create interactive administration tools in Java (portability is a compelling premise, although for some I suspect it is more of a "we won't write Windows code" thing). But honestly, they are doing a disservice to themselves and their customers. In a very short time Java has proven itself as a solid, powerful, and very capable server platform (and there are lots of examples of good Java based server software). But Java on the client? Remember those nasty things called applets? We've made baby steps since those days, apps have gotten better, and not much better.
For now, Java belongs on the server, not on the client.
January 7, 2004
I'll be back in London at the end of this month, and so another visit to the UKCFUG. This time I'll be sneak peeking Macromedia Flex. Registration for this event is required, go to http://www.ukcfug.org/.
January 5, 2004
A few of you asked to see the ActionScript code use to implement the query2tree() function used in the Flex example I posted last week. So, here it is: function query2tree(src) { // Define tree object var tree:XML = new XML(); // Define vars var recNo:Number, itemCount:Number; var rec:Object; var categElement:XMLNode, childElement:XMLNode; // Loop through records for (recNo=0; recNo<src.length; recNo++) { // Get record rec=src.getItemAt(recNo); // Is in same category as previous? if (categElement.attributes["label"] != rec["CATEGORY"]) { // If not, add new category node categElement = tree.createElement("node"); categElement.attributes["label"] = rec["CATEGORY"]; categElement.attributes["url"] = ""; tree.appendChild(categElement); itemCount=0; } // Add this item childElement = tree.createElement("node"); childElement.attributes["label"] = rec["LABEL"]; childElement.attributes["url"] = rec["URL"]; childElement.attributes["description"] = rec["DESCRIPTION"]; categElement.appendChild(childElement); categElement.attributes["description"]=++itemCount + " selections"; } // Return complete XML tree return tree; }
expects XML containing the menu structure, and uses "label" as the display label. This function creates that structure based on the contents of a ColdFusion returned query, each row is an item, and any time the category changes a new "folder" is created. Very simple code, for a very simple one-level deep menu, and hard coded for my example, but it does the trick.
I've been going back and forth on whether or not my CFC should return the complete XML. There would probably be performance gains in doing so, but at the same time I think my CFC code needs to not be tied to any specific client technology (and Flex is a ColdFusion client here). The jury is still out on this one.
January 4, 2004
Posted At : 10:11 AM
Related Categories:
Stuff
Stay on top of the Mars Exploration Rover Mission via NASA's Flash based M2K4 site at http://www.nasa.gov/externalflash/m2k4/frameset.html. Animations, images, Mars surface exploration, trivia and more.
January 2, 2004
My ColdFusion Resources page lists columns, articles, presentations and more. Over the years the list has grown to the point that the page requires about eight page-down scrolls to see the entire two column list. So, this page seemed like an ideal first Flex app; a tree control showing categories and listings, click to see details of each, and click the link to access the resources.
The new page (powered by Macromedia Flex) is at http://www.forta.com/cf/resources/.
And now for the code: <?xml version= "1.0"?> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" width="600" height="500" initialize="resourceService.GetTreeData()"> <!-- Include query2tree() function --> <mx:Script source="query2tree.as" /> <!-- Define the service --> <mx:WebService id="resourceService" wsdl="http://www.forta.com/cf/resources/service.cfc?wsdl" showBusyCursor="true"> <mx:operation name="GetTreeData" /> </mx:WebService> <!-- Define all bindings --> <mx:Binding source="query2tree(resourceService.GetTreeData.result)" destination="resourceTree.dataProvider" /> <mx:Binding source="Object(resourceTree.selectedItem.attributes).label" destination="resTitle.text" /> <mx:Binding source="Object(resourceTree.selectedItem.attributes).url" destination="resUrl.label" /> <mx:Binding source="Object(resourceTree.selectedItem.attributes).description" destination="resDesc.text" /> <!-- Title box --> <mx:VBox verticalGap="0" backgroundColor="#336633" borderStyle="none" widthFlex="1"> <mx:Label text="ColdFusion Resources" color="#FFFFFF" fontSize="20" fontWeight="bold" /> </mx:VBox> <!-- Body --> <mx:HBox> <!--- Resource tree on the left --> <mx:VBox> <mx:Tree id="resourceTree"width="250" heightFlex="1" /> </mx:VBox> <!-- Details on the right --> <mx:VBox widthFlex="1"> <mx:VBox borderStyle="outset" widthFlex="1" heightFlex="1"> <mx:VBox verticalGap="0" borderStyle="none" widthFlex="1"> <mx:Label id="resTitle" color="#336633" width="330" fontWeight="bold" /> <mx:Link id="resUrl" color="#336633" width="330" click="getURL(resUrl.label, '_blank')" /> </mx:VBox> <mx:TextArea id="resDesc" widthFlex="1" heightFlex="1" editable="false" wordWrap="true" borderStyle="none" /> </mx:VBox> </mx:VBox> </mx:HBox> </mx:Application> The code is actually very self-explanatory, but ...
defines the app, and specifies the app size (height and width).
The tag includes an external ActionScript file containing a function that converts returned query data into an XML format needed by the tree control below.
defines the Web Services used, this one points to a ColdFusion Component. This tag does not execute the SOAP call, that is done on startup using the initialize attribute in the tag.
Data bindings are the key to keeping data synchronized between controls. The behavior is a bit like using cell references in Microsoft Excel, once associated with each other, changes in one cell automatically propagate to other cells. The tag takes a source and destination, and ensures that the destination is updated whenever the source changes. The first binding associates the tree control with the results of the GetTreeData SOAP call. The next three bindings associate fields (used to display the title, URL, and description) with whatever is currently selected in the tree control.
The rest of the code is the display. A series of nested boxes (horizontal HBox tags and vertical VBox tags) provide containers for the display. defines the tree control. The right side of the screen contains a control to display the resource title, a control to display a linkable URL, and a control to display the description.
And that is it; 40 lines of code later I have an n-tier application that provides a much better user experience. The back end is the exact same CFC used in the original text version of the page, so no ColdFusion code changes were needed to implement this replacement interface.
Posted At : 2:36 PM
Related Categories:
Flex
I used much of my quiet time over the holidays to play with Flex (the in-beta product formerly known as Royale), and honestly, it's been a quite a while since I have had this much fun. Flex is highly addictive, and has that same instant-gratification feel that makes using ColdFusion such a pleasure.
I know that most of you have yet to play with Flex, and no, I am not telling you this just to rub it in. The point is that I have been given permission to post some of my Flex apps live on my site along with the source code, so as to share some of the experience with you.
The apps I'll be posting are all experiments and will likely keep changing as I keep tinkering; in addition, Flex is still in beta so stuff may not always work as intended and features are still likely to change between now and the time we ship, so please keep this all in perspective. Having said that, I'm excited to be able to share this with you, and eagerly await your comments and feedback.
More to follow.
Posted At : 1:17 PM
Related Categories:
Stuff,
Flash
This is just too cute for words, Make-a-Flake (at http://snowflakes.lookandfeel.com/) lets you design your own snowflake using paper, scissors, and Flash. This is a really nice example of Flashifying a familiar experience.
January 1, 2004
Posted At : 9:33 AM
Related Categories:
Stuff
2003 was a pretty intense and very hectic year. New products, a new baby, new books, over 150,000 actual miles logged, dozens of speaking engagements, a new blog, trips to over a dozen countries, a new Macromedia conference ... Wow! Thanks for all your support this past year, both personally and professionally, it is greatly appreciated.
So ... here's to a great, prosperous, peaceful, and even enjoyable 2004!
|
|