In a recent tutorial, Adobe's Christophe Coenraets gives a Java-friendly introduction to Flex, and shows how Flex can serve as a rich-client front-end to a Spring-based Java application.
With an Ajax client, you can connect to a back-end to [receive and send] mostly XML over HTTP. That means that on the server, you have to transform output [from the service interfaces] to an XML format suitable to the client... We think of Flex as a better view because via Flex you can directly invoke SOAP-based Web services. In addition, you can expose a POJO as a service, and invoke methods on that POJO from a Flex client across the network...
Developers often think that when they’re done with the server-side of an SOA application, they’re done building [that] application. But if you [at that point] tell your client-side developers [to] just access the new Web service, client-side developers will come back to say that their toolkits don’t support easy access to that Web service... As a client-side developer, you will have to go back to your server-side colleagues and have them develop some sort of an adapter to adapt a Web service [interface] to the user interface’s requirements. But the capabilities of the client should not have to dictate the way [an SOA] application exposes data on the server-side.
Coenraets recently expatiated upon Flex's ability to invoke a large variety of enterprise back-ends in an article, Using Flex with Spring. He points to four different ways a Flex client can converse with a back-end service:
You can use the HTTPService component to send HTTP requests to a server, and consume the response... The Flex HTTPService is similar to the XMLHttpRequest component available in Ajax.
You can use the WebService component to invoke SOAP-based web services.
You can use the RemoteObject component to directly invoke methods of Java objects deployed in your application server, and consume the return value...
In addition to the RPC-type services described above, the Flex Data Management Services provide a ... virtually code-free approach to synchronize data between the client application and the middle-tier.
In the article, Coenraets focuses on the last two methods, and illustrates how to take advantage of Flex's ability to invoke remote Java methods on a Spring back-end:
The whole idea behind Spring IoC is to let the container instantiate components (and inject their dependencies). By default, however, components accessed remotely by a Flex client are instantiated by Flex destinations at the server-side. The key to the Flex/Spring integration is therefore to configure the Flex destinations to let the Spring container take care of instantiating Spring beans.
The Flex Data Services support the concept of factory to enable this type of custom component instantiation. The role of a factory is simply to provide ready-to-use instances of components to a Flex destination (instead of letting the Flex destination instantiate these components itself).
Coenraets' article also provides a good introduction to Flex's programming model to Java developers:
The Flex programming model is made of...
ActionScript, an ECMAScript compliant, object-oriented programming model. With some syntactical differences, ActionScript looks and feels similar to Java, and supports the same object-oriented constructs: packages, classes, inheritance, interfaces, strong (but also dynamic) typing etc.
MXML: an XML-based language that provides an abstraction on top of ActionScript, and allows parts of an application (typically the View) to be built declaratively.
An extensive set of class libraries. The online API documentation is available here in a Javadoc-like format.
The Flex source code (.mxml and .as files) is compiled into Flash bytecode (.swf) that is executed at the client-side by the Flash virtual machine using a Just-In-Time compiler.
What do you consider as the biggest challenge today in developing rich interfaces to an enterprise application? The UI? Communication between client and server? Keeping data in sync between client and server data models? To what extent do you believe Flex helps solve those challenges?