Creating Applications with Mozilla-Chapter 7. Extending the UI with XBL- P4
Số trang: 19
Loại file: pdf
Dung lượng: 40.44 KB
Lượt xem: 2
Lượt tải: 0
Xem trước 2 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 creating applications with mozilla-chapter 7. extending the ui with xbl- 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:
Creating Applications with Mozilla-Chapter 7. Extending the UI with XBL- P4 Chapter 7. Extending the UI with XBL- P47.4.4. Extra Binding Content and Insertion PointsAll examples in the chapter have so far dealt with standard binding contentrendering within a bound document. The processes outlined in this sectioncan, in one sense, be seen as abnormal because they allow ordering of thecontent to change based on insertion points defined in the binding. Thisprocess is done with the XBL element7.4.4.1. Working with children of the bound elementZero or more children can be contained in anonymous content. Thesechildren are marked up with the XBL-specific tag. They canbe either the content of the element using the binding or anonymous contentgenerated by the base binding. If the tag contains its ownelements, then it will be used as the default content. If the element thebinding is attached to contains children, the default content will be ignored.The location of the tags determines the contents insertionpoint. Insertion points play an important role in the generation of contentwithin a template because they affect how the content is displayed andaccessed by the DOM. This stripped-down binding has only a vertical box as its own content andlooks to the children of the bound element for more content by using the element. Here is the XUL content that uses the binding: When the binding is attached and the content is drawn, the insertion pointfor the two labels is inside the container vertical box inside the binding. Thisscenario could be used when a binding is used multiple times. Each time, itneeds to be rendered differently with extra content that can be provided thisway.7.4.4.2. Selective inclusionSometimes multiple siblings are located within a box in the XUL, but youwant to use only some of them in the binding, such as when a user logs intoa system and content is displayed depending on its level of membership. Inthese cases, you can be selective about which children should be included inthe binding. Example 7-5 shows how to use the includes attribute on the element.Example 7-5. Selective inclusion of child content in a binding The children element in Example 7-5 essentially tells, Of all the contentcontained in the bound element, insert only the image element at thisparticular insertion point. Here is the XUL code that goes with thisexample: The image is the only child taken from the XUL content and the label isignored.If you have children that are not defined in the includes attribute, thenthe binding is discarded and not used. If the bound element uses anotherelement in addition to an image element, the binding is discarded and onlythe explicit content is used. If the image element isnt used at all, the bindingis discarded. This example renders the image and the label and discards the binding. Theanonymous content does not appear because the binding is discarded andonly the explicit content is used.7.5. InheritanceIn XBL, inheritance is the process in which one object included in anotherobject is allowed to use properties from that parent object. These propertiescan be many things, depending on the implementation, ranging frommethods to attribute property values. Inheritance is a concept familiar inprogramming languages, most notably object-oriented ones. Its notsomething alien to markup, however, and it is deployed effectively in XBL.This section examines three forms of XBL inheritance: binding, attribute,and implementation. As you will see, inheritance promotes self-contained(modular) and flexible bindings that permit shared content across and withinXBL documents.7.5.1. Binding InheritanceBinding inheritance occurs when one binding is linked to another binding orXUL element and uses some or all properties of it, whether they are contentor behavior. A binding can inherit from another binding that exists in thesame or different file. In one way, this useful feature makes a binding like aclass, with content and methods that can be used elsewhere. Bindingsbecome modules, which prevents code duplication, makes maintenanceeasier, and gets slotted in and out of documents.Linkage or inheritance is enabled by the extends attribute on the element. This attribute contains the URL of the binding thatyou inherit from. This URL is made up of the location and name of the filethat contains the binding (the # symbol), and the id of the specific bindingbeing used. In this way, it is similar to the access method used in CSSattachment.Although it is in the XBL 1.0 specification, Mozilla hasnt fullyimplemented type=inherits on the children tag yet, so the best wayto work with binding inheritance is to use the extends attribute. Example7-6 shows a few bindings used in the implementation of the listbox cellin the Mozilla tree. It illustrates how extends is used to inherit fromanother binding.Example 7-6. Binding inheritance In Example 7-6, listcell-iconic inherits listcell. In turn,listcell inherits list-box-base, which holds resources. Thelistcell binding is a cell with text only and the listcell-iconicbinding has text and an image. Thus, the user has a choice of using a list cellbinding with an icon or no icon. Yet both of these bindings have access tothe stylesheet resource declared in the base binding. If listcell-iconic is used, the duplicate xul:label is ignored in the inheritedbinding and the stylesheet inherited from the base binding via the inheritedbinding is used. Weve used this technique to illustrate how resources inmultiple bindings are shared.With ...
Nội dung trích xuất từ tài liệu:
Creating Applications with Mozilla-Chapter 7. Extending the UI with XBL- P4 Chapter 7. Extending the UI with XBL- P47.4.4. Extra Binding Content and Insertion PointsAll examples in the chapter have so far dealt with standard binding contentrendering within a bound document. The processes outlined in this sectioncan, in one sense, be seen as abnormal because they allow ordering of thecontent to change based on insertion points defined in the binding. Thisprocess is done with the XBL element7.4.4.1. Working with children of the bound elementZero or more children can be contained in anonymous content. Thesechildren are marked up with the XBL-specific tag. They canbe either the content of the element using the binding or anonymous contentgenerated by the base binding. If the tag contains its ownelements, then it will be used as the default content. If the element thebinding is attached to contains children, the default content will be ignored.The location of the tags determines the contents insertionpoint. Insertion points play an important role in the generation of contentwithin a template because they affect how the content is displayed andaccessed by the DOM. This stripped-down binding has only a vertical box as its own content andlooks to the children of the bound element for more content by using the element. Here is the XUL content that uses the binding: When the binding is attached and the content is drawn, the insertion pointfor the two labels is inside the container vertical box inside the binding. Thisscenario could be used when a binding is used multiple times. Each time, itneeds to be rendered differently with extra content that can be provided thisway.7.4.4.2. Selective inclusionSometimes multiple siblings are located within a box in the XUL, but youwant to use only some of them in the binding, such as when a user logs intoa system and content is displayed depending on its level of membership. Inthese cases, you can be selective about which children should be included inthe binding. Example 7-5 shows how to use the includes attribute on the element.Example 7-5. Selective inclusion of child content in a binding The children element in Example 7-5 essentially tells, Of all the contentcontained in the bound element, insert only the image element at thisparticular insertion point. Here is the XUL code that goes with thisexample: The image is the only child taken from the XUL content and the label isignored.If you have children that are not defined in the includes attribute, thenthe binding is discarded and not used. If the bound element uses anotherelement in addition to an image element, the binding is discarded and onlythe explicit content is used. If the image element isnt used at all, the bindingis discarded. This example renders the image and the label and discards the binding. Theanonymous content does not appear because the binding is discarded andonly the explicit content is used.7.5. InheritanceIn XBL, inheritance is the process in which one object included in anotherobject is allowed to use properties from that parent object. These propertiescan be many things, depending on the implementation, ranging frommethods to attribute property values. Inheritance is a concept familiar inprogramming languages, most notably object-oriented ones. Its notsomething alien to markup, however, and it is deployed effectively in XBL.This section examines three forms of XBL inheritance: binding, attribute,and implementation. As you will see, inheritance promotes self-contained(modular) and flexible bindings that permit shared content across and withinXBL documents.7.5.1. Binding InheritanceBinding inheritance occurs when one binding is linked to another binding orXUL element and uses some or all properties of it, whether they are contentor behavior. A binding can inherit from another binding that exists in thesame or different file. In one way, this useful feature makes a binding like aclass, with content and methods that can be used elsewhere. Bindingsbecome modules, which prevents code duplication, makes maintenanceeasier, and gets slotted in and out of documents.Linkage or inheritance is enabled by the extends attribute on the element. This attribute contains the URL of the binding thatyou inherit from. This URL is made up of the location and name of the filethat contains the binding (the # symbol), and the id of the specific bindingbeing used. In this way, it is similar to the access method used in CSSattachment.Although it is in the XBL 1.0 specification, Mozilla hasnt fullyimplemented type=inherits on the children tag yet, so the best wayto work with binding inheritance is to use the extends attribute. Example7-6 shows a few bindings used in the implementation of the listbox cellin the Mozilla tree. It illustrates how extends is used to inherit fromanother binding.Example 7-6. Binding inheritance In Example 7-6, listcell-iconic inherits listcell. In turn,listcell inherits list-box-base, which holds resources. Thelistcell binding is a cell with text only and the listcell-iconicbinding has text and an image. Thus, the user has a choice of using a list cellbinding with an icon or no icon. Yet both of these bindings have access tothe stylesheet resource declared in the base binding. If listcell-iconic is used, the duplicate xul:label is ignored in the inheritedbinding and the stylesheet inherited from the base binding via the inheritedbinding is used. Weve used this technique to illustrate how resources inmultiple bindings are shared.With ...
Tìm kiếm theo từ khóa liên quan:
thủ thuật máy tính công nghệ thông tin tin học quản trị mạng computer networkTài liệu liên quan:
-
52 trang 434 1 0
-
24 trang 362 1 0
-
Top 10 mẹo 'đơn giản nhưng hữu ích' trong nhiếp ảnh
11 trang 321 0 0 -
Làm việc với Read Only Domain Controllers
20 trang 314 0 0 -
74 trang 304 0 0
-
96 trang 299 0 0
-
Báo cáo thực tập thực tế: Nghiên cứu và xây dựng website bằng Wordpress
24 trang 293 0 0 -
Đồ án tốt nghiệp: Xây dựng ứng dụng di động android quản lý khách hàng cắt tóc
81 trang 287 0 0 -
EBay - Internet và câu chuyện thần kỳ: Phần 1
143 trang 277 0 0 -
Tài liệu hướng dẫn sử dụng thư điện tử tài nguyên và môi trường
72 trang 270 0 0