To learn more about how BlazeDS works and what it can do, you can take the BlazeDS Test Drive. The Test Drive
includes some sample applications that demonstrate basic capabilities and best practices for developing applications with BlazeDS.
你可以通过使用它的试用包,了解更多关于BlazeDS的运行和它的运行原理.BlazeDS试用包包括一些应用程序示例,这些示例展现了使用BlazeDS开发应用程序的能力和一些最佳实践.
Getting started with the Test Drive
开始试用包
Before you begin the BlazeDS Test Drive, you should be familiar with the Adobe Flex programming environment and how to use Flex to build rich Internet applications. For more information, see the Flex Help Resource Center.You must install BlazeDS to access the Test Drive.
在你开始运行试用包之前,你应该先熟悉Flex的编程环境,知道如何使用Flex来构建丰富的互联网应用程序.想了解更多的信息,请参考Flex帮助中心.你必须安装BlazeDS,以能够访问试用包.
After you start the Integrated BlazeDS server,open a browser and go to http://<hostname>:<port_num>. A link to the Test Drive appears at the top of the page. The Test Drive includes several sample applications: a catalog with mobile phone product information (one with text only, and the other with images), and a chat client.
启动整合了BlazeDS的服务器,打开浏览器访问http://<hostname>:<port_num>.这是一个访问试用包首页的链接.试用包包含了一些应用程序:一个移动电话信息的目录,一个聊天的客户端.
Sample 1: Accessing data using an HTTP service
例子1:利用HTTP服务访问数据
You can use the HTTPService component to send and receive HTTP requests by using HTTP GET or POST. The HTTPService component consumes different types of responses, but typically you use it to consume XML. HTTPService calls are asynchronous. You also use the component with any kind of server-side technology, such as JSP,Servlet, ASP, Ruby on Rails, and PHP.
你可以使用HTTP服务组件借助于HTTP的GET和POST发送和接受HTTP的请求.HTTP服务组件可以处理不同类型的响应,但是一般用来处理 XML的响应.HTTP服务的调用是异步的.该组件可以和任何类型的服务端技术一起使用,比如JSP技术,Servlet,ASP, Ruby on Rails和PHP.
In the sample, when you click the Get Data button, the data grid is populated with XML data returned by a JSP file.It shows built-in data grid capabilities such as sortable and movable columns. You can click the column head to sort data in ascending or descending order. Drag a column head to move a column of data to another location in the grid.You can also increase or decrease the width of the columns from the header row.
在这个例子里,当你点击"Get Data"的按钮,数据表格通过JSP返回的XML数据生成.这个例子展现了内置表格的能力,像分类和移动表格的柱.你可以点击表格的柱头以升序或倒序的方式排列数据.可以将一列的数据拖到表格的其它位置.你可以从表头增长或缩短列的宽度.
Sample 2: Accessing data using a web service
例2:利用web service访问数据
With the WebService component, you can invoke SOAP-based web services deployed on your application server or the Internet. WebService component calls are also asynchronous.
The sample also uses data grid column definitions. When you click the Get Data button, the grid is populated with data returned by a web service.
借助于WebService组件,你可以调用基于SOAP的web services发布在你的应用服务器或者互联网上.WebService组件的调用也是异步的.这个例子也是使用的表格.当你点击"Get Data"的按钮,数据表格通过web service返回的数据生成.
Sample 3: Accessing data using Java RPC
例3:利用Java远程调用访问数据
Like HTTPService and WebService components, Java RPC calls are also asynchronous. With the RemoteObject component, you can directly invoke methods of Java objects deployed in your application server, and consume the return value. The return values can be a primitive data type, an object, a collection of objects, or an object graph.
与HTTPService和WebService组件类似,Java远程调用也是异步的.借助于RemoteObject组件,你可以直接访问发布在应用服务器的Java对象,处理返回值.返回值可以是原始的数据类型,一个对象,对象的集合,或一个对象的图表.
In the sample, when you click the Get Data button, the grid is populated with data returned by the getProducts() method of the ProductService Java class.
在例3中,当你点击"Get Data"的按钮,数据表格通过直接调用ProductService类的getProducts()方法返回的数据生成.
Sample 4: Flex Programming Model 101
例4:Flex编程模型101
Like in any other object-oriented programming language, a Flex application is made of a collection of classes. Using Flex, you can create classes using MXML or ActionScript. You typically create view classes in MXML, and Model and Controller classes in ActionScript. After you define a class, you can use it programmatically or declaratively (as a tag in MXML) without the need for an additional descriptor file. Public properties are automatically available as tag attributes.
类似于其它面向对象的编程语言,Flex应用程序也是由类的集合构成.借助于Flex,你可 以用MXML和ActionScript来创建类.一般情况下,用MXML中创建视图类,用ActionScript创建控制器和数据模型类.在定义了一 类之后,你可以编程式地或声明地的使用这个类,不需要添加额外的描述文件.公共的属性自动成为标志的属性.
In this sample, basic Flex capabilities are displayed. When you click an image in the Catalog panel on the left side of the page, more information appears in the Product Details panel on the right.
这个例子展现了Flex的基本能力,当你点击页面左边的目录面板中的一个图片后,在右边的产品明细面板中会出现更多的信息.
Sample 5: Updating data
例5:更新数据
In this sample, you can update data from one panel of data and see the changes quickly displayed in another panel. The panel on the left shows a data grid with sortable, movable columns. When you click on a row in the Catalog panel on the left, detailed information about that item appears in Details panel on the right. In the Details panel you can modify data in any field, click Update, and the change is passed from the client side to the server side.
在这个例子中,你可以更新其中一块数据面板中的数据,然后会看另一块数据面板的变化.在左边的面板上是一个可以排序,拖动的数据表格.当你点击左边的一个 目录后,关于这个目录的详细信息会出现在右边的明细面板上.在明细面板上,你可以修改任一字段的数据,点击更新,所做的修改会从客户端传到服务端.
Sample 6: Publish-subscribe messaging (data push use case)
例6:发布和定阅消息(数据推送用例)
Flex supports publish-subscribe messaging through the BlazeDS Message Service. The Message Service manages a set of destinations that Flex clients can publish and subscribe to. Flex provides two components, Producer and Consumer, that you use to publish and subscribe to a destination, respectively.
通过BlazeDS的消息服务,Flex支持发布和定阅消息.Flex客户端可以发布和定阅消息服务管理的消息源.Flex提供了生产者和消费者模型的组件,你可以分别使用这些组件来发布和定阅消息.
In the example, a Java component publishes simulated real-time values to a message queue. The Flex client subscribes to that queue and displays the values in real time. Click the Subscribe To 'Feed' destination button. Pushed values appear in the text field. Click the Unsubscribe To 'Feed' destination button to stop the feed.
在这个例子中,一个java组件发布貌似实时的值到消息队列中,Flex客户端定阅这个消息队列,并实时的显示值.点击定阅到'Feed'消息源的按钮.推送的值将会在文本域显示.点击取消到'Feed'消息源的定阅的按钮停止响应.
Sample 7: Publish-subscribe messaging (collaboration use case)
例6:发布和定阅消息(协作用例)
The sample builds on the concepts and APIs introduced in sample 6. The messaging and real-time infrastructure available in Flex lets you build collaboration and data push applications to in a scalable and reliable manner while preserving the lightweight web deployment model.
Open the sample application in two different browser windows. Enter a message in the Send box at the lower edge of the page, and click the Send button. The message appears in the Chat windows in both clients.
这个例子是在例6的概念和API基础上建立的.保留轻量级的WEB发布模式,Flex的消息和实时基础结构让你能够以可伸地,可靠地方式建立协助和数据推 送应用.用不同的浏览器窗口打开示例程序.在页面下方的发信箱中输入消息,然后点发送按钮.消息会出现在这两个客户端的聊天窗口.