| By Yakov Fain | Article Rating: |
|
| January 15, 2008 07:30 AM EST | Reads: |
14,571 |
The XML file on the left is processed by the code on the right. The first three ActionScript trace statements demonstrate how you can access the elements and attributes of this XML stored in the variable myXML. The second line has a filtering criteria in parentheses: @id==2. This line means "find me all XML elements named item, and print the content of the element menuName for those that have the attribute id equal to 2. Pretty loaded and elegant line, isn't it?
After that, the code snippet above creates a newItem element and appends it to myXML, and then again uses dot notation to access XML elements and attributes.
From SOAP to JavaScript and FlashPlayer with ClearBI
ClearBI is a commercial Web reporter originally created for Flex/Java
applications and worked only with server-side applications that had
Adobe LiveCycle Data Services, which implemented a fast communication
protocol called AMF. But the newest version of ClearBI 1.1 can work
with the data that comes in a form of JavaScript objects, a Web
Service, or uses OpenAMF, an open source implementation of the AMF0
communication protocol.
In this section I'll go over the process of getting the data from Amazon's SOAP Web Service to JavaScript and then to ClearBI. This is what has to be done after the Web Service is initialized by WebService.swf. This time we'll use a JavaScript object as an argument to the operation KeywordSearchRequest.
Pass a JavaScript object with retrieval args to a hidden swf object, which will return the data back to JavaScript, which in turn passes the data to ClearBI swf:
var ws = com.farata.jsfx.WebServices("MyWebService"); // a hidden swf
Add a Web Service operation result listener. The next line maps the WebService.swf method serviceresult to JavaScript's function onJavaScriptResult that will receive the data from WebService.swf when available and will format it as JSON objects.
ws.addEventListener("serviceresult", onJavaScriptResult);
var args = {
KeywordSearchRequest: {
keyword: "AJAX",
page: "1",
mode: "books",
tag: "D3HW0PG66IPLAM",
type: "lite",
devtag: "D3HW0PG66IPLAM",
sort: null,
variations: null,
locale: null
}
};
Call Amazon's "KeywordSearchRequest" Web Service operation.
ws.Amazon.KeywordSearchRequest( args );
...
The JavaScript function receives the data arriving as JavaScript into a variable lastData.
function onJavaScriptResult(ev) {
lastData = ev.result.Details;
this.removeEventListener("serviceresult", onJavaScriptResult);
}
Now we can pass the data from lastData to clearBI.swf for displaying and customizing the report.
Pass the Data to ClearBI from a JavaScript Array
In JavaScript, get a reference to the Flash Player object and call the
function loadReport giving the report name (a template customized by
the user and stored in a database) and the data itself:
var report
report = $plugin("ClearBIPlayer"); // a helper function to return reporter's id
report.loadReport(reportName, lastData);
The data exchange between JavaScript and ClearBI.swf is supported internally by the ActionScript class ExternalInterface. The report variable above represents ClearBI.swf, which internally (in ActionScript) allowed JavaScript calling its function loadReport, which is mapped to ActionScript's loadReport function.
ExternalInterface.addCallback("loadReport", loadReport);
That's all there is to it. End users can run and customize reports themselves. For example, their Web browser window may look like Figure 4. The top portion of the screen is regular JavaScript while the report and its editor are rendered by Flash Player 9.
Using a Faster Communication Protocol: OpenAMF
If
you're building your application in-house and it doesn't have to
connect to someone else's Web Service, you may be better off creating a
Java-based data feed using faster communication protocol called
OpenAMF. This open source implementation of the AMF communication
protocol performs serialization of the server-side POJO into its
ActionScript peer on the client (see Figure 5). This is how it goes:
- Client: A Web browser with Flash Player 9 plug-in or ActiveX
- Mid-tier: A servlet container with open source OpenAMF (five jars), open source Flex SDK, ClearBI's jars to support report compilation and hot deployment, JOTM, JTS, JDBC drivers
- Report persistence: ClearBI uses two database tables to store reports' metadata (can be co-located with other data)
- Report publishing: Reports can be compiled into swf files and published on the Web
You can download the description of the API for the JavaScript wrapper to WebService.swf at www.myflex.org/demo/webservice_swf/doc/. The WebService.swf is located at www.myflex.org/demo/webservice_swf/WebService.swf .
The trial version of ClearBI 1.1 became available on October 15, 2007 at www.myflex.org.
The demo application that uses JavaScript, WebService.swf, and ClearBI.swf is deployed at www.myflex.org/theriabook/ClearBI.Ajax/main.html. It looks like Figure 6.
In the first three tabs you'll be able to play with sending XML and JavaScript requests to Amazon, and the last three tabs are supported by ClearBI (the name of the report is Amazon.KeywordSearchRequest. You might want to watch a short pre-recorded demo that shows working with a sample Employees database and using ClearBI editor for report customization. This demo is located at . It shows how end users can add grouping, modify styling, and apply formulas.
Published January 15, 2008 Reads 14,571
Copyright © 2008 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Yakov Fain
Yakov Fain is a Managing Director of Farata Systems, consulting, training and product company. He has authored several Java books, dozens of technical articles. SYS-CON Books released his latest co-authored book , Rich Internet Applications with Adobe Flex and Java: Secrets of the Masters in Spring 2007. Sun Microsystems has nominated and awarded Yakov with the title Java Champion. He leads the Princeton Java Users Group. He is an Adobe Certified Flex Instructor. Currently Yakov works on the book for O'Reilly "Enterprise Application Development with Flex". He twits at twitter.com/yfain.
- Kindle 2 vs Nook
- Cloud Computing on Gartner's Top 10 List and SYS-CON Events' 2010 Calendar
- Confessions of a Ulitzer Addict
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Moving Your RIA Apps into the Cloud: Seven Challenges
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Windows 7 – Microsoft’s First Step to the Cloud
- Ulitzer Provides a Powerful Social Journalism Platform
- Jill Tummler Singer, Deputy CIO of CIA, Keynotes at GovIT Expo
- Open Source Mobile Cloud Sync and Push Email
- Kindle 2 vs Nook
- The Difference Between Web Hosting and Cloud Computing
- Cloud Computing on Gartner's Top 10 List and SYS-CON Events' 2010 Calendar
- Ajax in RichFaces 3.3, JSF 2 and RichFaces 4
- Confessions of a Ulitzer Addict
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- My Thoughts on Ulitzer
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- US Post Office Hops a Ride on NetSuite’s Cloud
- Moving Your RIA Apps into the Cloud: Seven Challenges
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Building a Drag-and-Drop Shopping Cart with AJAX
- What Is AJAX?
- Google Maps! AJAX-Style Web Development Using ASP.NET
- Flashback to January 2006: Exclusive SYS-CON.TV Interviews on "OpenAjax Alliance" Announcement
- AJAXWorld Conference & Expo to Take Place October 2-4, 2006, at the Santa Clara Convention Center, California
- AJAX Sponsor Webcasts Are Now Available at AJAXWorld Website
- How and Why AJAX, Not Java, Became the Favored Technology for Rich Internet Applications
- "Real-World AJAX" One-Day Seminar Arrives in Silicon Valley
- AJAXWorld University Announces AJAX Developer Bootcamp
- AJAX Support In JadeLiquid WebRenderer v3.1
- Where Are RIA Technologies Headed in 2008?
- Struts Validations Framework Using AJAX




































