4.4. Running through a Complete Example

This section walks through an example that shows the BlazeDS remoting service in use. I use Apache Tomcat as the Servlet container and deploy a BlazeDS instance in it. From Chapter 2, you know how to deploy BlazeDS in Tomcat and many other mainstream Java application servers. For convenience, I also use Flex Builder as my IDE.

In this example, I take the energy consumption data for United States between the years 1949 and 2007 and depict that in a data grid and a time series line chart.

The data is accessible from a POJO service object called EnergyConsumptionDataService. The data itself manifests in an object-oriented format and is transferred as such. The consumption for individual data points for the time interval is encapsulated in an object called EnergyConsumption. The data for the entire time interval is a collection of such objects. The EnergyConsumption class has the following attributes:

  • year

  • fossilFuels

  • nuclearElectricPower

  • renewableEnergy

  • total

As a first step, I create a Flex project in Flex Builder and choose a J2EE server. To keep all the code in one place in a uniform manner I also choose to create a combined Java/Flex project using WTP (Web Tools Platform). WTP comes as a part of the Ecplise JEE version and you will benefit from installing it. Figure 4-5 shows the first screen where this initial project information is specified.

Figure 4.5. Figure 4-5

Next, I point the target runtime to my local Tomcat installation. The assumption ...

Get Professional BlazeDS: Creating Rich Internet Applications with Flex® and Java® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.