Autodesk 15606-011408-9300 Developer Guide - Page 104
Creating the Report Scripts, from Autodesk MapGuide
UPC - 606121429548
View all Autodesk 15606-011408-9300 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 104 highlights
When a user runs the Incidents (CF) report, Autodesk MapGuide prompts the user to specify a point. Then it invokes getpoint.cfm, passing the point's lat/lon coordinates as URL parameters. For example, if the user specified a point with coordinate values of 37.721,-121.943, the URL would be: http://www.yourserver.com/getpoint.cfm?LAT=37.721&LON=-121.943 Creating the Report Scripts Next we'll create the three CFM files: getpoint.cfm, showform.cfm, and insert.cfm. The first CFM file, getpoint.cfm, creates a small browser window and then calls a second file, showform.cfm, passing along the coordinate values it received from Autodesk MapGuide: window.close(); var loc = "showform.cfm?LAT=" + #LAT# + "&LON=" + #LON#; win = window.open(loc,"ShowFormWin", "width=300,height=170,dependent=yes,resizable=yes"); win.focus(); Note that getpoint.cfm consists of a single element containing a block of JavaScript code; because the file doesn't display any text, no other HTML tags are needed. Let's look at the code line by line. When getpoint.cfm is first called, it uses a default browser window similar to the one we saw in the previous example. The first line of code closes that window. Note Because the browser parses the entire block before running the first line of code, we can safely close the window, knowing our script will continue to run. Be aware, however, that this strategy will get you into trouble if your file contains function calls or other multiple blocks. See your JavaScript documentation for more information. The next line constructs a URL and assigns it to a variable called loc. Note that the line is a mix of both JavaScript code and ColdFusion tags. The tags contain two ColdFusion variables named #LAT# and #LON#. These variables are replaced on the server by the lat/lon values that Autodesk MapGuide provided, meaning the browser receives a line similar to the following: var loc = "showform.cfm?LAT=" + "37.721" + "&LON=" + "-121.943"; The effect of this line is to create a variable called loc and to assign it the value showform.cfm?LAT=37.721&LON=-121.943. 104 | Chapter 6 Using Reports to Query and Update Data Sources