
815
DEVELOPING
COLDFUSION 9 APPLICATIONS
Requesting and Presenting Information
Las
t
upda
te
d 8/5/2010
The callback handler can be useful to provide information about a successful navigation operation. For example,
you could make a pod's title bar italic to indicate loading (just before the navigate call), and use the callback handler
to switch it back to normal once the navigate completes. Similarly, if a pod is shows pages from a book, the callback
handler could update a page number in a separate field once a page loads
•
You can use the special
controlName
_body
variable to access and change the body contents for
cfpod
and
cfwindow
controls. For example, you can use the
controlName
_body.innerHTML
property to set the body HTML.
For
cfpod
and
cfwindow
tags, you can also use the
controlName
_title
to get or set the title bar contents of the
control.
These different techniques provide you with flexibility in writing your code. For example, the
ColdFuson.navigate
function and the
controlName
_body
variable provide similar functionality. However, with the
controlName
_body
technique, you make explicit Ajax requests to get markup for the body, and the JavaScript functions in the retrieved
markup might not work properly.
ColdFusion.navigate
takes care of these issues. Therefore, limit use of the
controlName
_body
technique to simpler use cases.
The following example shows how you can use various techniques to change container contents. It consists of a main
page and a second windowsource.cfm page with text that appears in a main page window when you click a button. The
main page has a
cfpod
control, two
cfwindow
controls, and the following buttons:
•
The “Simple navigate” button calls a
ColdFusion.navigate
function to change the contents of the second
window.
•
The “Change w2 body & title” button replaces the second window’s body and title innerHTML values directly to
specific strings.
•
The “Change pod body” button changes the pod body innerHTML to the value of the second window’s title
innerHTML.
The following example shows the main page:
<html>
<head>
<!--- Callback handler puts text in the window.cfm callback div block. --->
<script language="javascript">
var mycallBack = function(){
document.getElementById("callback").innerHTML = "<br><br>
<b>This is printed by the callback handler.</b>";
}
<!--- The error handler pops an alert with the error code and message. --->
var myerrorHandler = function(errorCode,errorMessage){
alert("[In Error Handler]" + "\n\n" + "Error Code: " + err "\n\n" +
"Error Message: " + errorMessage);
}
</script>
</head>
<body>
<cfpod height="50" width="200" title="The Title" name="theTitle">
This is a cfpod control.
</cfpod><br>
<!--- Clicking the link runs a ColdFusion.navigate function that replaces the second window's
contents with windowsource.cfm. The callback handler then updates the window
contents further. --->
<cfwindow name="w1" title="CF Window 1" initShow=true
x=10 y=200 width="200">
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...