Danh mục

Creating Applications with Mozilla-Chapter 7. Extending the UI with XBL- P1

Số trang: 17      Loại file: pdf      Dung lượng: 51.05 KB      Lượt xem: 3      Lượt tải: 0    
Thu Hiền

Hỗ trợ phí lưu trữ khi tải xuống: 19,000 VND Tải xuống file đầy đủ (17 trang) 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- p1, 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- P1 Chapter 7. Extending the UI with XBL- P1You now know that XUL is the basic tool set for creating your applicationinterface, but even it has limitations. It is just a finite set of widgets that yourprogramming needs may transcend. If you find that you reimplement manyof the same groups of widgets in different applications, or if you want toextend your applications interface in some other way, you will find theeXtensible Binding Language (XBL) an invaluable tool.This chapter describes what XBL is and how it is used. Basically, XBLprovides a way to attach new content or behavior to your application byusing XBL bindings. XBL can extend, add to, and reorganize user interfaces.XBL can also help you organize scattered XUL code into a set of self-contained widgets that make building and maintaining your Mozillaapplication much easier. Appendix C provides a reference for the XBLelement set, with which new elements can be created.7.1. What Is XBL?XBL is an XML markup language invented specifically for creating widgets.XBL looks similar to XUL, and may even contain XUL or HTML and othermarkup (see the Section 7.1.3 section later in this chapter for moreinformation about how other markup is used in XBL bindings), but itspurpose is different. Flexibility and interoperability are the point of XBL.If the XUL textbox is inadequate, for example, you can use XBL to createand attach a new widget called , possibly based ontextbox, that provides special attributes and functionality for validatinginput data against a database.A binding is a single XBL language entity that can contain content as othermarkup (such as XUL) behavior that is represented as methods andproperties, and event-handling capabilities. Bindings can be anything fromsmall widget objects to large, complex blocks of code with extensivefunctionality. Figure 7-1 shows the different components that make up abinding: fields, properties, functions, event handlers, and content. Thesection Section 7.2, later in this chapter, provides more detail about abindings structure.Figure 7-1. Mozilla XBL binding structureBindings differ from XUL overlays because they are fully self-contained,reusable, and generally have no dependencies outside of the binding itself.Although XUL is used most often as content in an XBL binding, XBL canalso bind to and from HTML and XML. If you have worked with Java orC#, you may recognize some parallels between XBL bindings and Javaobjects.7.1.1. XBL TerminologyThe following terms are used to describe XBL and its use in the XPFE:XBL An acronym for the eXtensible Binding Language. In some contexts, the term XBL refers to actual code (e.g., the XBL in this example . . . ). XBL is an XML syntax.Binding A single unit of the XBL language, one or more of which is contained in a binding document. Most bindings are made up of content and implementation, although each are mutually exclusive; if you add event handlers to that list, each one can appear on its own in a binding.Binding document An XBL file with an .xml extension that contains one or more bindings.Bound document A XUL (or HTML) document that has one or more bindings attached to it as content.Bound element A bound element is a widget or element that uses a particular binding. It can be an existing element in the XUL or HTML set or a newly invented one.Anonymous content Content (e.g., XUL elements) contained in a binding that is hidden from the document object (DOM). Refer to the section Section 7.4, later in this chapter, for a more detailed discussion of its characteristics and how to programmatically gain access to the content.Attachment and detachment Attachment is the process through which a binding is associated with a bound element. It is essentially a way of telling the element which binding to use. Detachment is the process of removing that link and with it, the binding display.Insertion point The point in anonymous content at which children of the bound element are inserted. The section Section 7.4.4, later in this chapter, details the insertion process.Inheritance During inheritance, characteristics of one object are passed on to another object. In XBL, this process is multifaceted. Bindings can inherit from other bindings, anonymous content can inherit attributes from the bound element, and a binding implementation can inherit the behavior of another widget. All concepts are explained in the section Section 7.5, later in this chapter.7.1.2. An XBL DocumentXBL documents are files saved with an .xml filename extension. Mostbindings implement XUL content and behavior with script, so XBL filesreside in your XUL applications chrome content area and have full access toXPConnect-wrapped XPCOM objects.Several bindings often reside inside the same XBL file. Performancebenefits from this arrangement, if you have multiple related bindings,because only one XBL document needs to be loaded, rather than multipledocuments. Organization is another factor. Mozilla has dozens of bindingsthat are interrelated by either inheritance or filename identifiers. Individualpieces to a menu widget reside in a file called menu.xml, button bindingsare in button.xml, and so forth. Keeping these bindings together is wise.The XBL documents root container is the tag. Inside thiselement is one or more individual child bindings, defined by the tag. A simple XBL document is as follows: An XBL document is a valid XML document. The XML preamble you areused to seeing in XUL files is present. It also contains the single rootelement (in this case, ) and the child nodes that define thebindings (empty ...

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