39,59 €
Backbase is a very powerful and complex JavaScript library, with many user interface components to help make web development easier. It allows the development of Rich Internet Applications (RIA) that run within all major browsers but its powers and complexity mean that the choice of component can be overwhelming. Understanding when and how to use the right component might not always be straightforward. This book makes that easier.
This is a practical book that teaches you how to use the Backbase Client Framework effectively, with a complete overview and many examples. A core developer of the framework puts the technologies used into a wider perspective of existing web standards and a seasoned software architect explains why XML-based UI definition produces better web applications.
The transparent use of AJAX technologies, for example to submit forms, or to retrieve updates for data grids, can be taken for granted with the Backbase framework. Packed with examples, the book shows you how to get the most from the library of UI components, and then extend the library with its own custom language. With this book in hand, it is easy to enable AJAX within your web application. You will be able to use the Backbase framework effectively, from basic applications to complex, custom-defined UI components.
This book contains a complete overview of all the UI libraries available within the Backbase framework and shows examples for each element described.
The Backbase framework offers an innovative Tag Definition Language (TDL), which allows developers to create new UI components that can be used as XML elements, in the same way as using the built-in GUI library. Using TDL brings considerable development advantages, and this book explains how.
Significant attention is also given to architectural aspects of designing a web-application, showing sample applications using a model-view-controller approach.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 584
Veröffentlichungsjahr: 2009
Copyright © 2009 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: December 2009
Production Reference: 1041209
Published by Packt Publishing Ltd.
32 Lincoln Road
Olton
Birmingham, B27 6PA, UK.
ISBN 978-1-847199-12-6
www.packtpub.com
Cover Image by Vinayak Chittar (<[email protected]>)
Authors
Ghica van Emde Boas
Sergey Ilinsky
Reviewers
Deepak Vohra
Jerry Spohn
Peter Svensson
Acquisition Editor
Douglas Paterson
Development Editor
Dilip Venkatesh
Technical Editor
Wilson D'souza
Copy Editor
Ajay Shanker
Indexer
Hemangini Bari
Editorial Team Leader
Abhijeet Deobhakta
Project Team Leader
Priya Mukherji
Project Coordinator
Ashwin Shetty
Proofreader
Lynda Sliwoski
Graphics
Nilesh R. Mohite
Production Coordinator
Adline Swetha Jesuthas
Cover Work
Adline Swetha Jesuthas
Ghica van Emde Boas is an independent IT Consultant. She was employed by IBM in the Netherlands for 30 years as a relational database developer, as an IT Architect, and as a Java developer involved with the largest Java framework ever written—the IBM SanFrancisco Framework. She has been taking part in the development of object-oriented methodologies within IBM. She has been teaching these at IBM's Object Technology University in Belgium and the USA.
Ghica has co-organized several workshops on Generative Model Transformations at OOPSLA (Object-oriented Programming, Systems, Languages, and Applications) conferences, the place where it all happened: objects, design patterns, modeling wars (UML), eXtreme programming, and Agile development. She now specializes in PHP, MySQL, and web application development. She helped write the client framework documentation for Backbase.
Ghica has written two books in Dutch about PHP and MySQL for Pearson Education, and has contributed considerably to the Dutch translation of "Foundations of Ajax", by Ryan Asleson and Nathaniel T. Schutta, Apress. While at IBM, Ghica participated in writing two Redbooks and published two articles, one in the IBM Journal of Research and Development and the other in the IBM Systems Journal.
Ghica lives and works in the Netherlands. She is married and has three children. She likes rowing on the Spaarne River.
First of all, I would like to thank Dimitra Retsina, Jouk Pleiter, and Gerbert Kaandorp from Backbase for their enthusiasm about this book-writing project and for supporting me by allowing access to all information about the Backbase framework that I needed.
Sergey Ilinsky deserves my gratitude for his spontaneous offer to be a co-author and for the fierce discussions we had, which were always interesting.
Without the help of the R&D crew at Backbase, this book would contain a lot more errors and fewer examples. Thanks!
The Planning & Scores group at the ROC Eindhoven (a very large school in the Netherlands) helped me by developing widgets that I could use in the sample application, while Geert Broekmans wrote the PHP database framework used in the sample application of the book.
I am truly grateful for the help and useful comments from the reviewers and the staff at Packt Publishing.
Of course writing this book would not have been possible without the ongoing support for my information technology related adventures, from my husband, Peter.
Sergey Ilinsky is a senior UI engineer at Nedstat BV and a Tech Lead for an open source project at Clientside OY. He has worked for Backbase for three years, evangelizing open-standards based software development, while engineering and developing core parts of the Backbase Client Framework.
Having been heavily involved with client-side development since 2003, he became an expert in many standard and proprietary web technologies. He is also a contributor to some of the modern web-related specifications. Sergey can frequently be found on AJAX or client-side technology related forums, or he can be met at international developers' conferences where he occasionally gives talks.
I would like to thank Backbase for the opportunity they gave me to work and improve on this beautiful piece of software—the Backbase Ajax Client Framework—and later for letting me join the project of writing this book.
Thanks to Ghica van Emde Boas, the main writer of the book, who I had the pleasure to work with and who never sent me a third email reminder whenever I delayed my part.
Thanks to the staff of Packt Publishing involved in this book project.
I would like to express special gratitude to my girlfriend, Elena O., for her tolerance and ongoing support.
Deepak Vohra is a consultant and a principal member of the NuBean.com software company. Deepak is a Sun Certified Java Programmer and Web Component Developer, and has worked in the fields of XML and Java programming and J2EE for over five years. Deepak is the co-author of the book "Pro XML Development with Java Technology", Apress and was the technical reviewer for the book WebLogic: The Definitive Guide", O'Reilly. Deepak was also the technical reviewer for the book "Ruby Programming for the Absolute Beginner", Course Technology PTR and the technical editor for the book "Prototype and Scriptaculous in Action", Manning Publications. Deepak is also the author of the books "JDBC 4.0 and Oracle JDeveloper for J2EE Development", Packt Publishing and "Processing XML Documents with Oracle JDeveloper 11g", Packt Publishing.
Jerry L. Spohn is a Manager of Development for a medium-sized software development firm in Exton, Pennsylvania. His responsibilities include managing a team of developers and assisting in architecting a large, multilingual, multi-currency loan accounting system, written in COBOL and Java. He is also responsible for maintaining and tracking a system-wide program database documentation web site, for which he uses DotNetNuke as the portal.
Jerry is also the owner of Spohn Software LLC, a small consulting firm that helps small businesses in all aspects of maintaining and improving their business processes. This includes helping with the creation and maintenance of websites, general office productivity issues, and computer procurement. Spohn Software, as a firm, prefers to teach their clients how to solve their own problems internally, rather than require a long-term contract, thereby making the business more productive and profitable in the future.
Jerry currently resides in Fleetwood, Pennsylvania. He enjoys spending time with his two sons, Nicholas and Nolan.
Peter Svensson is a developer, architect, father, and runs his own company—Greener Grass AB. When he's not arranging the Scandinavian Web Developer Conference or managing the Stockholm Google Technology User Group, he develops rich web applications using the Dojo AJAX Toolkit and no Flash whatsoever. He's also the author of "Learning Dojo", Packt Publishing.
Thanks to my loving family for supporting my crazy stunts, frequent flights, and benevolent maniacal schemes.
This book is about squaring the circles of web applications. It deals with the Backbase Client Framework.
Before you put this book away because you think that squaring circles is rather vague and mathematically impossible, let's hasten to say that this book will give you a solid foundation in web application programming using the Backbase Client Framework.
Now, before you again think of putting this book away because you are not sure why you should use the Backbase framework instead of one of the many other JavaScript frameworks or libraries out there, give us a chance to briefly explain what squaring the circles of web applications means and what the Backbase framework has to do with this.
Here is a set of rhetorical questions: Would it not be nice if you have an extensive library of UI widgets that could be used in the same way as HTML? If you could extend HTML with new widgets and components in any way you like? If you could use AJAX almost transparently? If you could bind data retrieved dynamically from a server in flexible ways to any widget, in particular to complex data grids?
Of course, that would be nice for a number of reasons. First of all, XML-based UI definition languages such as HTML have been proven to be a very effective and natural way to lay out web pages. UI designers are familiar with them and have good tools to help them make good designs.
Therefore, the UI designer or the developer who plays this role should be able to define the UI using an XML-based UI definition language directly. It should not be necessary to generate the HTML or UI definition in complex ways using a server scripting language such as PHP or JSP; even worse is constructing the DOM tree to define the UI using JavaScript. This is because it is very hard to predict what the final result on the web page will be from the perspective of the UI designer. Yet, this is a common practice today.
Rich UI widgets will have rich interaction with each other and with a server. For example, to retrieve new data dynamically from a database to be displayed in a table, a drop-down list, or a report, and so on. Common interaction patters involve also submitting form data that can be used for updates on a server.
Creating rich interaction is a programmer's job. On the client side, you will want to use JavaScript and on the server side, you have a choice of options according to your preference or that of your developers. The question is how do you prevent polluting your nice, clean, square-bracketed XML-based UI definition language with the round JavaScript objects that you need to implement the desired behavior?
The answer is the Backbase Client Framework. For details of how this happens and how you really square the circles, we refer to the rest of this book. But let's briefly introduce the framework here: the Backbase Client Framework is a standards-based, server independent, cross-browser framework to create Rich Internet Applications (RIAs).
RIA development is usually associated with either Adobe Flex or Microsoft Silverlight. Although both have similar XML-based UI definition languages, the main difference with the Backbase framework is that they need a plugin to run, whereas the Backbase framework does not because it is developed in JavaScript.
Backbase allows the development of web applications that run within all major browsers, whereas developers are able to use established standards for XHTML, DOM, CSS, XPath, and XSLT, even if the browser used does not support them. The transparent use of AJAX technologies, for example to submit forms or to retrieve updates for data grids, can be taken for granted with the Backbase framework.
This book teaches you how to use the Backbase framework effectively from Hello Backbase to complex custom-defined UI components. The book contains a complete overview of all UI libraries available within the Backbase framework and shows examples for each element described. It teaches you how to develop your own widgets, providing a comprehensive overview of the Backbase Tag Definition Language (TDL) and by showing interesting, non-trivial examples.
Significant attention is given to the architectural aspects of designing a web application, showing sample applications using a Model-View-Controller approach.
Here is a summary of the chapter contents:
Chapter 1: Hello Backbase!, walks you through the steps to set up your development environment.
The famous Hello World is shown in many variations: with only basic JavaScript, a Backbase UI widget together with basic JavaScript, a Backbase Tag Library widget together with the Backbase XML Execution Language, and finally using AJAX communication with a server script.
This chapter teaches you something about XML namespaces.
Chapter 2: User Interface Development, provides a closer look at the Backbase UI markup languages and their XML namespaces. We give an overview of the Backbase Tag Library (BTL) and details about the UI layout widgets in BTL.
The proper layout of an application user interface involves styling with CSS. We describe how CSS can interact with the BTL widgets and how you can go about styling in your web application.
Chapter 3: Writing the Application Logic, provides more details about the execution logic of a web application. We look at the Backbase programming model and the various APIs it provides. In particular, we look at the Backbase XML Execution Language and at the Command Functions.
We add a few new BTL widgets to our repertoire: the Info and Notify widgets.
Chapter 4: Client-server Communication and Forms, covers subjects that range from low level details about asynchronous communication between client and server, to high level web application architecture.
We show you the details of forms support, including validation options, in the Backbase framework and list the widgets available in this category.
We will start applying the knowledge acquired in these four chapters to design and develop a sample application for a travel blog site, the C3D sample application.
Chapter 5: Data-bound Widgets, deals with data binding which is an interaction between a data source, usually residing on a server (for example, a database), and a data observer is usually an object on the client that can map this data to a UI widget.
In this chapter we discuss data binding, the data-bound widgets in the Backbase framework, and how you can make your own widget.
The most powerful data-bound widget in the Backbase framework is the dataGrid. With 11 examples, we explore many details of using this grid.
Chapter 6: More Dynamic Behavior, talks about:
Behaviors: Generic functionality that you can attach to any Backbase element.
The built-in behaviors, in particular the drag-and-drop behavior: how you can influence the dragging of elements and the things you can do when the element is dropped. We also discuss the resize behavior with its options.
Command functions to add, remove, or set behaviors dynamically.
The broadcaster/observer elements and functions.
Animation with the Synchronized Multimedia Integration Language (SMIL).
Chapter 7: Creating UI Components, gives a lot of detail about the Tag Definition Language (TDL), the most interesting and unique feature of the Backbase framework. We show that you can build powerful UI components using TDL, which promises new ways of doing web application development.
Chapter 8: Widget Wrap-Up, covers almost all the remaining BTL widgets and command functions. We will look in detail at actions, menus, and windows.
Chapter 9: Debugging, Optimization, and Deployment, shows that the Backbase tool set, especially the debugger, has an advantage over other tools because it works with all browsers. In addition, the Backbase debugger allows you to inspect your Backbase application structure and all custom built widgets easily.
Using the guidelines set forth by the YSlow tool, we describe what you can do to optimize a Backbase web application.
We look at deploying the Backbase framework libraries, optimizing the TDL bindings, and using the optimized versions of the bindings delivered with the Backbase package.
Chapter 10: Framework Comparison, is a rather theoretical chapter that will show you a way to look at the various JavaScript frameworks available and how to categorize them.
We illustrate with an example the difference in coding style for a pure JavaScript framework as opposed to the Backbase framework using XML for UI layout. We also illustrate how easy it is to integrate other frameworks into the Backbase framework.
Chapter 11: The Square Web Application, formulates what a square web application is and how to develop one.
This last chapter provides a last look at the C3D travel blog sample application. It shows changes and updates according to the make it work, make it right, make it fast principle. The details of uploading an image and of including a Google map are included.
We end the chapter by developing a square puzzle.
This book includes many examples. All examples are provided in the sample code for this book in an easily operational form. Many examples only require a browser to run. You will need a web development environment, as explained in Chapter 1, to run the examples where server interaction is involved. Later in the book, you will need to set up a database to run the C3D sample application.
This book is for web developers who want to develop applications using the Backbase Client Framework. It may also be interesting for web developers and web application architects who want to know more about XML-based web application architectures.
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text are shown as follows: "We can include other contexts through the use of the include directive."
A block of code is set as follows:
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "clicking the Next button moves you to the next screen".
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an email to <[email protected]>, and mention the book title via the subject of your message.
If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or email <[email protected]>.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book on, see our author guide on www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Downloading the example code for the book
Visit http://www.packtpub.com/files/code/9126_Code.zip to directly download the example code.
The downloadable files contain instructions on how to use them.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration, and help us to improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to any list of existing errata. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or web site name immediately so that we can pursue a remedy.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
You can contact us at <[email protected]> if you are having a problem with any aspect of the book, and we will do our best to address it.
In this chapter, we will say "hello!" to the Backbase Client Framework. We will explain how to download the framework and how to install it. Then, we will discuss how to set up a new application that'll show "Hello World!". At the end of this chapter, we will also show a simple page layout using a Backbase panelSet widget. We will expand this page into a client web application in later chapters.
In each chapter, we will cover some background information that will help you understand how the Backbase framework works. In this chapter we will look at the following subjects in more detail:
The Backbase Client Framework is a standards based, server independent, cross-browser solution to creating web applications, ranging from traditional to desktop-like. It uses AJAX technologies to easily develop and deploy Rich Internet Applications.
This is a mouthful of a definition. Let's look at the meaning of those terms first:
In addition to the Client Framework, Backbase offers a set of extensions for the Java environment. It includes a JavaServer Faces (JSF) extension, a generic connector for JSP or Struts, and a Data Services extension. These extensions are not discussed in this book.
If you are like us and like many web developers, you may have started writing simple HTML when developing web applications. After a while, you may have decided to separate presentation from structure and to give your web pages a better look using CSS. The next thing in your evolution as a web developer would have been making your pages more user friendly and interactive, by creating tool tips, pop-up windows, tab boxes, and by validating forms before submitting. Maybe you did this using little pieces of JavaScript downloaded from the Web or by building your own JavaScript function libraries. On top of this, you may have tried to give your web applications the look and feel of a desktop application by using AJAX, requiring more JavaScript everywhere.
Now, what happened to the source code of your web pages? Again, if you are like us, over time the HTML code became littered with many pieces of JavaScript. It became difficult to see what the structure of the page was, even more so when you tried to generate the HTML code from PHP or JSP or some other server-side scripting language. Perhaps, you found out too that it is really hard to make a web page that will show well in all major browsers.
Would it not be nice if there was...
The Backbase Client Framework is such a framework. We will call it Backbase most of the time, which is also the name of the company that built the framework. Backbase can be used freely. There is no difference between the commercial and the community edition, except for the license, which states that you should not deploy it commercially on a server with more than two processors.
This book is intended to make you an expert in using the Backbase framework. We will cover just enough of AJAX, XML, XHTML, namespaces, XPath, CSS, and the Document Object Model (DOM) to make the Backbase framework easier to use, and to understand why Backbase is built like it is. While doing so, we hope that we can increase your knowledge of the core client web technologies and how they relate to each other. With this knowledge, you can evaluate Backbase against other frameworks and decide which one suits your purpose the best.
To round off this introduction, let's summarize the advantages of using the Backbase Client Framework:
Let us first take a look at what the Backbase framework contains. On the Developer Network site of Backbase, there is a set of demos that you can view online or download for further inspection. The URL for this site is http://bdn.backbase.com/client/demos.
These demos include Sample Application Layouts, a Progressive Enhancement Demo, a Rich Forms Demo, and Coexistence Demos. You can take a look at those and run them online, but according to our opinion, they are only mildly interesting, except for the Backbase Explorer.
The Backbase Explorer allows you to view all UI widgets from the Backbase Tag Library ( BTL); you can see the source code that is needed to show the example, and you can change the source code to see what happens. For example, if you click on Windows & Dialogs | window management | windowArea, you can see something like this:
The Backbase Explorer is an interesting and useful application that can be used to learn more about the Backbase framework and about the widgets it offers.
Also, take a look at the Sample Application Layouts on the same online demo page. This will give you an idea of the kind of layouts you can easily make using Backbase. We will use a simplified version of one of these as the starting point for the example application that we will be developing throughout the book.
Each of the demos is downloadable and contained in a ZIP file. When unzipped, it can execute immediately on your local PC because the essential parts of the Backbase framework are included with it.
Before we start looking at the Backbase Client Framework, you may want to consider the setting up of a development environment that you will need to execute the examples provided in the book or to develop your own applications. We assume that you already have experience with web application development. Therefore, we will keep it short.
To try out the application we are developing, you will need a web server, a language environment that you can use to develop the server side of your application, and a browser in which you can execute your application.
To serve web pages locally, you need to have a web server installed on your local PC. You can use any web server you like in combination with the Backbase framework. For example, popular web servers are Apache and IIS.
Also, you will need a server scripting language, such as JSP or PHP. Backbase will work with all server languages, therefore the choice is yours. Just remember that Backbase can communicate with any web server and any server scripting language that outputs the right XHTML to the browser.
If you already have a local development environment set up, then that is fine. Keep using it! Otherwise, you could obtain the XAMPP package, which you can download from: www.apachefriends.org. This package is really easy to install and includes Apache, PHP, MySQL, PHPMyAdmin, and more. It is available for several operating systems including various types of Linux, Mac OS, and Windows.
Examples in this book that require communication with a server will mostly use PHP because that is the easiest environment to set up, and also easy to understand, even if you are not familiar with it.
There exists a JSF version of Backbase framework, which offers tight integration with JavaServer Faces (JSF). We are not discussing the JSF version of the Backbase framework in this book.
To execute and view the application we are developing, you need a browser. The browser landscape is changing very fast. A year ago, there would have been only one recommendation that we would have made here: use Mozilla Firefox! Not only because it is a good browser, but mainly because of Firebug, the debugging plugin for Firefox. Firebug gives you the ability to edit, debug, and monitor CSS, XHTML, JavaScript, and network traffic live in any web page viewed in the browser. You can find Firebug at http://www.getfirebug.com.
Today, there are a lot more browsers that do a good job at implementing web standards and that offer good debugging facilities such as Google Chrome, Safari, and Microsoft Internet Explorer 8.
A handy plugin to use for Microsoft Internet Explorer prior to version 8 is the MSIE Developer Toolbar. It provides a variety of tools for quickly creating, understanding, and troubleshooting web pages in the MSIE browser. Search for Developer Toolbar at http://www.microsoft.com/downloads/.
We should specifically mention the Backbase debugger. This is a Firebug style debugger that will work across all supported browsers. It will start automatically in the Backbase development environment when something goes wrong. It will help you to debug applications in browsers for which no good tools are available.
Although many examples shown in this book and in the Backbase documentation do not really require communication with a server, you may not be able to execute them locally by typing the file location as URL in the browser because of security restrictions in the browser you are using.
Firefox is an example of such a browser. You can lift this restriction in Firefox by placing a file with the name user.js (if it does not exist) in the defaults/pref folder of the browser and adding the following line:
pref("security.fileuri.strict_origin_policy", false);
If you are a Windows user, you may be able to find this folder here: C:\Program Files\Mozilla Firefox\defaults\pref.
Be aware of the security risks you are taking though!
You will need more than one browser to test your application. A considerable percentage of the users of your web application will be using browsers other than the one you chose to develop with, and unfortunately, even Backbase cannot guarantee that your application will look the same in all browsers. At the minimum, you should have Mozilla Firefox and Microsoft Internet Explorer available for testing.
In addition to a web server, you will need a tool that you can use to edit your application source code. Although any text editor such as Notepad is sufficient, you will be more productive if you use a suitable Integrated Development Environment (IDE). Again, if you already use an IDE that you are comfortable with, please keep using it. Otherwise, we would recommend installing the Eclipse IDE. Eclipse is an open source IDE with many plugins available for specific development tasks. One of those is a Backbase plugin that will help with code completion. This plugin is included in the package when you download the Backbase framework. However, Eclipse can be downloaded from http://www.eclipse.org. Be sure to download a version of Eclipse with web development capabilities already included. A plugin that supports PHP, of which there are several available, is useful too.
As an alternative, you could consider Aptana Studio, an Eclipse-based IDE that is targeted at AJAX developers. Among many features, it has support for Adobe Air application development. It has many plugins for all kinds of handy development tasks. You can download Aptana as a standalone application or as an Eclipse IDE plugin from http://www.aptana.com.
Your development environment is now set up; therefore, it is time to download Backbase Client Framework from http://www.backbase.com/download.
Once you have downloaded the package, which comes as a ZIP file, you can unzip it to a convenient location. The unzipped package should look similar to this:
Warning: What we describe here is the structure of the Backbase package as you can find it on the Web at the time of writing. Changes have occurred in the past and may happen again.
In order to use the Backbase framework, your web server must send it to a browser. Therefore, we must copy the framework to a location where the web server can find it. Your web server serves its pages from its document root. Its default location for the document root can be very different depending on the web server you are using and by configuring the web server, you can have multiple roots at almost any location in the file system on the host of your web server.
Let's assume that your development web server is Apache from the XAMPP package and that you have installed it on the C: drive. The default document root is then: c:\xampp\htdocs. The easy way to install the Backbase framework is to copy the backbase folder found in the web folder and paste it as a subfolder of htdocs. For the time being, you can delete the 4_4_1_optimized folder that you just copied. You will need the optimized version of the framework only when you are actually deploying your application on a publicly visible server.
There is one more thing we would like to take care of before we really start. It will save a lot of useless book space if we can explain what a typical starter page for the Backbase framework looks like and then forget about it. Of course, the examples that are supplied with this book are all ready to execute and therefore this source code will repeat the skeleton page code where required.
For any Backbase enabled page, you need an HTML file, usually named index.html, which looks like this:
The version number of the Backbase Client Framework release is specified in the [version] folder name (for example, 4_4_1). If your version of the Backbase Client Framework is different from the one shown here, you must adapt the code samples accordingly.
There are some interesting points:
At the place where it says: <!-- YOUR APPLICATION CODE GOES HERE -->, you can put your application code. We will call this a Backbase area. The code that you can put here can be ordinary XHTML, widgets that are provided by Backbase, or widgets that you have built yourself.
The <!-- YOUR APPLICATION CODE GOES HERE --> part is contained within script tags with type="application/backbase+xml". The type attribute signals the Client Runtime that it should process the contents. The xml part of the type attribute says that the contents should be proper XML.
There can be multiple Backbase area's areas. In fact, there can be as many areas as you like. This is convenient if you are converting an older web application to a Backbase application or when you have large chunks of conventional HTML in your application. As the Backbase framework takes some overhead to process this HTML, there is a performance advantage to put code that does not require processing by the Client Runtime outside a Backbase area.The code in a Backbase must adhere to XHTML standards and most importantly, all tags must be properly closed. This can be a source of errors if you are converting an older application where for example <input> and <img> tags are often not closed. Another XHTML violation to watch out for is that attribute values in tags must be enclosed in quotes and all attributes specified must have a value. For example, you should code selected="selected" instead of just selected in a select box.The Backbase JavaScript engine in boot.js is loaded in the header of the HTML page. It is very important to make sure that you have a proper path specification here. Many times, when you set up a new application, you get an empty page at your first try to see your application. The cause is almost always that your path specification is wrong. If this happens to you, it is convenient to use a tool like Firebug to see what the server returns and why it cannot find the Backbase libraries.To use the Backbase widgets, you must include the configuration files, also called implementation bindings for the tags:The HTML tag contains two namespace declarations—xmlns="http://www.w3.org/1999/xhtml" and xmlns:xi="http://www.w3.org/2001/XInclude". The XHTML namespace is the default namespace and therefore you do not need to add a prefi x in front of the XHTML tags. The XInclude namespace is declared with the xi prefi x, which you saw used in front of the include statement that was used to include the Backbase confi guration files. For now, just remember that you need them and that it is important to declare namespaces appropriately in your code. Later in this chapter, there is a section that explains what you really need to know about XML, XHTML, and namespaces. The Backbase Client Framework uses several specifi c Backbase XML namespaces in addition to providing implementation for several standard ones like the XInclude. We will see some examples in the next section.
The document starts with: <!-- -->. This is done to enforce quirks mode in the Microsoft Internet Explorer browser. This is a requirement for the Backbase Tag Library widgets to allow box elements to be rendered consistently across browsers.
As we said earlier, the startup index.html file is very similar for all applications. All you have to do when you set up a new application is copy the starter skeleton to a proper place in the file system where your server can find it, and adjust the path settings in such a way that the Backbase libraries can be found. Also, give your HTML document the proper title and meta-information in the head section.
From now on, we will usually take for granted that you know how to surround our example code shown in the book with the right skeleton code.
