ColdFusion 8 Developer Tutorial

ColdFusion 8 Developer Tutorial Adobe ColdFusion is an application server, renowned for rapid development of dynamic websites, with a straightforward language (CFML), powerful methods for packaging and reusing your code, and AJAX support that will get developers deep into powerful web applications quickly. This book is the most intense guide to creating professional ColdFusion applications available. Packed with example code, and written in a friendly, easy-to-read style, this book is just want you need if you are serious about ColdFusion. This book will give you clear, concise and, of course, practical guidance to take you from the basics of ColdFusion 8 to the skills that will make you a ColdFusion developer to be reckoned with. ColdFusion expert John Farrar will teach you about the basics of ColdFusion programming, application architecture, and object reuse, before showing you a range of topics including AJAX library integration, RESTful Web Services, PDF creation and manipulation, and dynamically generated presentation files that will make you the toast of your ColdFusion developer town. This book digs deep with the basics, with real-world examples of the how and whys, to get more done faster with ColdFusion 8. This book also covers the new features of ColdFusion 8 Update 1

pdf10 trang | Chia sẻ: tlsuongmuoi | Lượt xem: 2336 | Lượt tải: 0download
Bạn đang xem nội dung tài liệu ColdFusion 8 Developer Tutorial, để tải tài liệu về máy bạn click vào nút DOWNLOAD ở trên
ColdFusion 8 Developer Tutorial John Farrar Chapter No. 10 "CF AJAX Programming" For More Information: www.packtpub.com/coldfusion-8-developer-tutorial/book In this package, you will find: A Biography of the author of the book A preview chapter from the book, Chapter NO.10 "CF AJAX Programming" A synopsis of the book’s content Information on where to buy this book About the Author John Farrar started working with computer programming around 1977. He has had the opportunity to work on projects used by Apple, Blue Cross, Brunswick Recreation, Casio, GVSU, Johnson Controls, Sprint, and many others. This history covers over 30 years of knowledge and experience in the industry. He started doing web development over ten years ago. In the early days of the Web, ColdFusion stood out to him not just as a way to make web pages into web applications but as a maturing solid platform good for the developer, site owner, and end users. He started at version 4.5 and has been enjoying every version upgrade more and more. John owns a company called SOSensible. His company does work for large companies but has a special focus on also making sure technology is approachable beyond the enterprise. It has developed a number of Open Source solutions including COOP. COOP is a mix of "Custom Tags" and "CFCs" that provides structure while keeping development simpler. It demonstrates his love for the things that make ColdFusion/CFML a delightful language to build websites. COOP is a pet project of his that can allow upgrades of AJAX libraries and add in features as the libraries grow. For More Information: www.packtpub.com/coldfusion-8-developer-tutorial/book He has spoken at national and regional conferences, online meetings, and area user group meetings. He is also an Adobe User Group manager. John knows that community is a viable and productive tool to build developers and the companies they serve. He has learned much from great resources in the community including bloggers, books, conferences, and resources to great in number to mention here. He blogs them at and encourages others to join in and build the community with him. Contact: johnfarrar@sosensible.com Alternative Email: sosensible@gmail.com. Thanks to Douglas Paterson, and the many staff members of Packt Publishing for helping me through my first published book. The guides and interaction were a great experience that helped me in numerous ways. There were a couple of community editors who helped review technical content. These assistants were Sean Corfield and Rick Mason and many of the suggestions made by them have been added to this book and are on file towards any revisions in the future. The efforts of the various people who work on Open Source and share their work with the community at large should be appreciated. Several were kind enough to work with me if there were any questions in writing this book and it is truly appreciated. Also thanks to the love of my life, Jeanine, who enthusiastically motivated me to see the book through to completion. For More Information: www.packtpub.com/coldfusion-8-developer-tutorial/book ColdFusion 8 Developer Tutorial Adobe ColdFusion is an application server, renowned for rapid development of dynamic websites, with a straightforward language (CFML), powerful methods for packaging and reusing your code, and AJAX support that will get developers deep into powerful web applications quickly. This book is the most intense guide to creating professional ColdFusion applications available. Packed with example code, and written in a friendly, easy-to-read style, this book is just want you need if you are serious about ColdFusion. This book will give you clear, concise and, of course, practical guidance to take you from the basics of ColdFusion 8 to the skills that will make you a ColdFusion developer to be reckoned with. ColdFusion expert John Farrar will teach you about the basics of ColdFusion programming, application architecture, and object reuse, before showing you a range of topics including AJAX library integration, RESTful Web Services, PDF creation and manipulation, and dynamically generated presentation files that will make you the toast of your ColdFusion developer town. This book digs deep with the basics, with real-world examples of the how and whys, to get more done faster with ColdFusion 8. This book also covers the new features of ColdFusion 8 Update 1. What This Book Covers Chapter 1 describes how to enhance basic HTML pages with the power and simplicity of ColdFusion. It also explains the difference between static HTML pages and dynamic ColdFusion pages. Chapter 2 describes how to create object classes and instantiate object instances. It also describes the object constructors. This chapter explains how to connect to a database through the internal methods of our objects. Chapter 3 helps us in understanding how to manage multiple products through common forms for listing, editing, and adding data. This chapter explains integrating and streamlining the workflow of web forms and CFC database processing. In Chapter 4, we will learn how to use the web server memory to create engaging and interactive web applications by using variable scopes. We will also learn how to share some information, and how to protect the rest of the information in a controlled manner. For More Information: www.packtpub.com/coldfusion-8-developer-tutorial/book In Chapter 5, we will learn about the basics of custom tags. We will also learn how to integrate cfinclude for libraries of segments. This chapter also includes skinning a website by using custom tags, the use of nested tags, and so on. Chapter 6 includes wrapping of the ThickBox gallery functions into a custom tag for simple functional reuse and wrapping of a Google map library into our code with a custom tag for simplified interactive maps. This chapter helps us in understanding how to create a multi-state form list wrapped in a custom tag. In Chapter 7, we will see how to use the authentication that comes standard with CF. This chapter explains how to control the site content based on current user permissions. In Chapter 8, we will see how AJAX is different from HTML and regular server-oriented web pages. This chapter includes the comparison of HTML, server, and browser technology sites. It also explains about the ColdFusion widgets. In Chapter 9, we will see the benefit received from the combined power of tag-based encapsulation with AJAX functionality. Chapter 10 explains about binding, proxy connections, JSON features, Spry data integration, and debugging. In Chapter 11, we will have a look at the different ways in which we can reorganize pages of PDF documents into a new PDF file from one or more separate PDF source documents. Chapter 12 explains how to create Verity search collections, how to initialize the Verity indexes, how to interface with the indexes. This chapter also explains how to interface with PDF content for more control when calling documents. Chapter 13 discusses files, emails, and images. This chapter helps in understanding how some of the common ColdFusion features empower developers to shift the web pages to web applications in many ways. In Chapter 14, we will learn how to interact with other web servers and create features on our site that will allow others to interact with us. Chapter 15 gives a broad introduction to ColdFusion's way of generating dynamic reports. This chapter also gives a brief introduction to the ColdFusion Report Builder tool. Chapter 16 shows the unique presentation capabilities built into ColdFusion. It gives practical examples to help build custom presentations with dynamic content on demand. Appendix A covers some important details of setting up a development environment. It also includes some important tips for better productivity. Appendix B includes some links and resources that are aimed at giving us a good starting base of information. It also explains a group of libaries that prove to be very significant. For More Information: www.packtpub.com/coldfusion-8-developer-tutorial/book CF AJAX Programming This chapter deals with AJAX programming in ColdFusion. ColdFusion acts a great platform not just because of its code features, but because of its characteristics as to how the code interacts with other features. ColdFusion is a language with depth and power. Yet, as we developers know, it seems real power always requires a bit of custom code. In this chapter, we will have a look at the following topics: Binding Proxy connections JSON features Spry data integration Debugging Binding When it comes to programming, the two most commonly used features are CFAJAXProxy and binding. The binding feature allows us to bind or tie things together by using a simpler technique than we would otherwise have needed to create. Binding acts as a double-ended connector in some scenarios. You can set the bind to pull data from another ColdFusion tag on the form. These must be AJAX tags with binding abilities. There are four forms of bindings, on page, CFC, JavaScript, and URL. Let's work through each style so that we will understand them well. We will start with on page binding. Remember that the tag has to support the binding. This is not a general ColdFusion feature, but we can use it wherever we desire. • • • • • For More Information: www.packtpub.com/coldfusion-8-developer-tutorial/book CF AJAX Programming [ 200 ] On Page Binding We are going to bind 'cfdiv' to pull its content to show on page binding. We will set the value of a text input to the div. Refer to the following code. ColdFusion AJAX elements work in a manner different from how AJAX is written traditionally. It is more customary to name our browser-side HTML elements with id attributes. This is not the case with the binding features. As we can see in our code example, we have used the name attribute. We should remember to be case sensitive, since this is managed by JavaScript. When we run the code, we will notice that we must leave the input fi eld before the browser registers that there has been a change in the value of the fi eld. This is how the event model for the browser DOM works. This is my edit box. And this is the bound div container. Notice how we use curly brackets to bind the value of the 'myText' input box. This inserts the contents into 'div' when the text box loses focus. This is an example of binding to in-page elements. If the binding we use is tied to a hidden window or tab, then the contents may not be updated. CFC Binding No w, we are going to bind our div to a CFC method. We will take the data that was being posted directly to the object, and then we will pass it out to the CFC. The CFC is going to repackage it, and send it back to the browser. The binding will enable the modifi ed version of the content to be sent to the div. Refer to the following CFC code: For More Information: www.packtpub.com/coldfusion-8-developer-tutorial/book Chapter 10 [ 201 ] <cffunction name="getDivContent" returntype="string" access="remote"> <cfreturn "This is the content returned from the CFC for the div, the calling page variable is '#arguments.edit#</ strong>'."> From the previous code, we can see that the CFC only accepts the argument and passes it back. This could have even returned an image HTML segment with something like a user picture. The following code shows the new page code modifi cations. This is my edit box. And this is the bound div container. The only change lies in how we bind the cfdiv element tag. Here, you can see that it starts with CFC. Next, it calls bindsource, which is the name of a local CFC. This tells ColdFusion to wire up the browser page, so it will connect to the CFC and things will work as we want. You can observe that inside the method, we are passing the bound variable to the method. When the input fi eld changes by losing focus, the browser sends a new request to the CFC and updates the div. We need to have the same number of parameters going to the CFC as the number of arguments in our CFC method. We should also make sure that the method has its access method set to remote. Here we can see an example results page. For More Information: www.packtpub.com/coldfusion-8-developer-tutorial/book CF AJAX Programming [ 202 ] It i s valid to pass the name of the CFC method argument with the data value. This can prevent exceptions caused by not pairing the data in the same order as the method arguments. The last line of the previous code can be modifi ed as follows: JavaScript Binding Now, we will see how simple power can be managed on the browser. We will create a standard JavaScript function and pass the same bound data fi eld through the function. Whenever we update the text box and it looses focus, the contents of the div will be updated from the function on the page. It is suggested that we include all JavaScript rather than put it directly on the page. Refer to the following code: This is my edit box. And this is the bound div container. updateDiv = function(myEdit){ return 'This is the result that came from the JavaScript function with the edit box sending "'+myEdit+'"'; } Here is the result of placing the same text into our JavaScript example. For More Information: www.packtpub.com/coldfusion-8-developer-tutorial/book Chapter 10 [ 203 ] URL Binding We can achieve the same results by calling a web address. We can actually call a static HTML page. Now, we will call a .cfm page to see the results of changing the text box refl ected back, as for CFC and JavaScript. Here is the code for our main page with the URL binding. This is my edit box. And this is the bound div container. In the above code, we can see that the binding type is set to URL. Earlier, we used the CFC method bound to a fi le named bindsource.cfc. Now, we will bind through the URL to a .cfm fi le. The bound myText data will work in a manner similar to the other cases. It will be sent to the target; in this case, it is a regular server-side page. We require only one line. In this example, our variables are URL variables. Here is the handler page code: 'This is the result that came from the server page with the edit box sending "#url.myEdit#"'

Các file đính kèm theo tài liệu này:

  • pdfColdFusion 8 Developer Tutorial.pdf
Tài liệu liên quan