Using Flex Builder 2 you will be able to build complete Flex applications powered by a ColdFusion backend. And you can build them even without using Flex Enterprise Services (FES for short).
But having said that, your application may indeed benefit from FES. We’ll be exposing additional FES functionality in future betas, but for now we have made one important FES capability as simple to use as you’d expect from ColdFusion. I am referring to the ability to push content down to the Flash client without needing the client to poll or refresh on timed intervals. For example, a real-time auction application with price changes reflected as they occur, or a charting application plotting data in real-time, or a management application that shows you the status of users and sessions within your application. FES refers to this functionality as “publish-subscribe”, clients can subscribe to a thread and when data is published they receive it automatically.
The ColdFusion hook into FES is via an event gateway (so yes, this will require ColdFusion Enterprise, and it will also work with the Developer Edition). When the ColdFusion/Flex Connectivity update is installed, a new gateway type called “FlexMessaging” will be added to ColdFusion. You can create instances of this new gateway type to communicate with FES (inbound and outbound).
To help you get started, the following is the simplest possible example of ColdFusion Flex communication via FES, an example of ColdFusion publishing and Flex consuming. It creates a simple HTML form used to post messages which then appear in real-time in a Flex Text box.
Here goes:
- This assumes that FES is installed and running (it should be configured
and running before you start CF). - If you have not yet done so, be sure to enable the CF adapter in
flex-message-service.xml (in C:fes2jrun4serversdefaultsamplesWEB-INFflex
if you used the default FES install), here is what one could look like (with
commented out stuff removed):
*
127.0.0.1
- It also assumes that you have a gateway defined in CF Admin named
“Flex2CF” of type FlexMessaging (no config file is needed, and you can point
to any CFC), and that that gateway is running. - The following is a simple CFM file with a form that self-posts and
submits to the gateway for processing:
Message sent.
Message failed.
Message:
document.form1.message.focus();
- Create a new project in Flex Builder, be sure to select YES when asked if
the project will be using Flex Enterprise Services, and create the project under the Flex default server samples folder (C:fes2jrun4serversdefaultsamples if you are using the default installation). - This is the entire Flex app. It is a simple text box which displays the
received messages. It also shows the connection and subscription state at
the bottom (they should generally both always be true).
Try it out. You should be able to type messages in the CF page in your web
browser, and they’ll show up in the Flex app.
Leave a Reply