Danh mục

Flex 3 with Java- P4

Số trang: 50      Loại file: pdf      Dung lượng: 663.51 KB      Lượt xem: 10      Lượt tải: 0    
Jamona

Xem trước 5 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Tham khảo tài liệu flex 3 with java- p4, công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả
Nội dung trích xuất từ tài liệu:
Flex 3 with Java- P4 Chapter 5 {selectedBook.author.firstName} {selectedBook.author.lastName} [ 137 ]Working with XML In the code above, we have used the HBox, VBox, and Panel containers to lay outthe main user interface. We have also added a TileList component to displaybooks using a custom component, that is, BookDetailItemRenderer.mxml asits itemRenderer. Next, we have added another Panel container to display theselected books details using a Form container. We have used data binding to bindthe selected books details with individual labels in the Form container, for example,text={selectedBook.title}. The selectedBook is an XML object which will bepopulated with the selected books details when you select an item in the TileListcomponent using its change event. The TileList control displays a number of items laid out in tiles. It displays a scroll bar to access all items in the list. You can use its direction property to control the direction in which this control lays out its children. To know more about the TileList control, see Flex 3 language reference at http://livedocs.adobe.com/ flex/3/langref/mx/controls/TileList.html.Next, we have created another Panel container to create the shopping cart userinterface and added a DataGrid component to display cart details. The DataGridcomponent is using data binding to display information from the shoppingCartArrayCollection object, which will contain individual selected book nodes. We willpopulate the shopppingCart array in the addToCartHandler() method, which isthe event handler for the addToCart custom event. [ 138 ] Chapter 5In the ActionScript code block, we have defined a method called init() toinitialize the applications resources and variables. This method is called in theapplication tags creationComplete event. In this method, we have registeredan event handler for the addToCart event which will be dispatched by theBookDetailItemRenderer.mxml custom component.Notice that BookDetailItemRenderer.mxml is acting as an itemRenderer of aTileList component, so there is no straight way to add an event listener to it.Therefore, to handle events from the itemRenderer component in its parent, youneed to dispatch an event from custom component by setting its bubble argumentto true. When an event is dispatched with the bubble argument set to true, Flexsearches for event listeners in the bottom to top order—that is, from event targetto root display object. When it finds an appropriate event listener anywhere in itsdisplay hierarchy, it delivers an event to it. This is a simple way to communicatewith your application from itemRenderers.Next, we are loading XML file using URLLoader and setting its result to the xmlDataXML object, which is used as the dataProvider of the TileList component.xmlData.book refers to individual node(s) from the XML file.Now we are ready with our application. Once we compile and execute thisapplication, you would see the following screen:You can play with this application. You can try selecting different items from theTileList control and see how it changes display in the Details panel, and see whathappens when you click on the Add to cart button. [ 139 ]Working with XMLSummaryIn this chapter, you learned what E4X is and how to use it to work with XML data.You also learned various Flex classes to work with XML data, and how to loadexternal XML files and use XML as a data provider. You also created a samplebooks explorer application using various concepts such as custom component,event creation, data binding, and E4X.In the next chapter, you will learn about Adobes LiveCycle Data Services and whatis the BlazeDS platform. [ 140 ] Overview of LiveCycle Data Services and BlazeDSLets begin this chapter by understanding the real meaning of the term Rich Internetapplications (RIAs). RIAs are web-based applications that are rich in presentingdynamic content that goes beyond the traditional request and response model. Flexis a presentation technology, which means that it sits over many existing middlewaretechnologies such as Java, .NET, ColdFusion, and PHP. The purpose of Flex is tobuild data-intensive applications that provide richer and engaging experience to theend user.You can leverage your existing server-side infrastructure and choose Flex as yourpresentation layer. Flex integrates well with J2EE (Enterprise Edition) or server-sideJava technologies using an additional server-side layer known as LiveCycle DataServices or BlazeDS deployed on your application server. This additional layerfacilitates your Flex application to invoke and communicate directly with Java classeson the server so that they can be called and accessed from the Flex application.Many third-party remoting and messaging implementations are availableto communicate with different server-side technologies such as AMFPHP(www.amfphp.org) for PHP, AMF.N ...

Tài liệu được xem nhiều: