YOUR FEEDBACK
José D'Andrade wrote: "...it may never be released..." Why? "...if Midori isn’t heir to Windows Mi...
AJAXWorld RIA Conference
$300 Savings Expire August 8
Register Today and SAVE!


2007 West
GOLD SPONSORS:
Active Endpoints
Your SOA Needs BPEL for Orchestration
BEA
Virtualized SOA: Adaptive Infrastructure for Demanding Applications
Nexaweb
Overcoming Bandwidth Challenges with Nexaweb
TIBCO
What is Service Virtualization?
SILVER SPONSORS:
WSO2
Using Web Services Technologies and FOSS Solutions
Click For 2007 East
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
TOP COLDFUSION LINKS


User Configurable Reports Using Report Builder
A great tool for providing end users with well formatted, browser-independent reports

Delivering well-formatted reports through a web browser has always been a problem. Style sheets and cross browser compatibility are just a few of the many issues we, as developers, have to deal with when creating HTML based reports. Fortunately, with the release of CFMX 7 Macromedia has provided us with a great tool for providing end users with well formatted, browser independent reports: ColdFusion Report Builder.

Now that we have the Report Builder, life is perfect (at least when it comes to delivering reports via the web) - right? We have one tool to create a query and a perfectly formatted report in a matter of minutes. Well, let's not get too excited too fast -there are some limitations to using the report builder to build your queries and deliver your web-based reports. What if your database table or column names change after you've created a report? What if the query for your report changes, or worse yet, is wrong? What if each user wants to see specific subsets of data in a customized report? You don't want to go into the report builder and re-create your .cfr file (ColdFusion Report) every time your end users throw you a curveball.

One way to fix this problem would be to store your query for the report in a .cfm file, use the report builder to create a blank report and manually add the fields to the report, then use the report wizard to format your report. This solution would let you easily change the query that runs your report.

Now we can easily change the queries behind our reports, but what if an end user wants to change the report? What if a user would also want, for instance, last week's sales report, or a sales report for a specific customer? Writing a separate query for each report a user requests would quickly become a nightmare to maintain. Wouldn't it be convenient to let users configure their own reports?

Here's how you can do just that. By using a database to store the report's properties, a component to represent a Report object, ColdFusion Report Builder to build your report templates, and .cfm files to handle your display logic and manipulate the report object you can create reports that users can easily modify to their needs.

Building a Report
The first thing to do is to create the base reports. The base reports are the reports the user will select as the template for their user modified report. When a user customizes a report, they are actually cloning one of the base reports.

The first step in creating a base report is to use a SQL query builder tool to write a SQL statement to get the data for the report. For the first base report I'll create a Year-To-Date Sales by Salesperson report. The query is pretty straight forward, however, one thing to note is that I use table and column name aliases because I had columns from different tables that have identical names - after all, we want to take a look at a "real-life" situation. Here's my query:


SELECT
C.name AS Customer
,P.name AS Product
,E.firstName + ' ' + E.lastName AS SalesPerson
,J.quantity
,S.saleDate
,P.price
,P.price * J.quantity AS TotalCost
,S.id
FROM
Customer C
INNER JOIN
Sale S ON S.customerId = C.id
INNER JOIN
JoinSaleProduct J ON J.saleId = S.id
INNER JOIN
Product P ON P.id = J.productId
INNER JOIN
SalesPerson E ON E.id = S.salespersonId
WHERE
DatePart(yyyy,s.saleDate) = DatePart(yyyy,GetDate())
ORDER BY S.id
Let's take a step back and look at the SQL for the base Year-To-Date Sales report. This works very nicely because there is no static date in the WHERE clause; however, it won't lend itself very easily to modification by the common user. Using a DatePart() statement isn't something many end users will be familiar. A user-modifiable version of the above query might look like this:

SELECT
C.name AS Customer
,P.name AS Product
,E.firstName + ' ' + E.lastName AS SalesPerson
,J.quantity
,S.saleDate
,P.price
,P.price * J.quantity AS TotalCost
,S.id
FROM
Customer C
INNER JOIN
Sale S ON S.customerId = C.id
INNER JOIN
JoinSaleProduct J ON J.saleId = S.id
INNER JOIN
Product P ON P.id = J.productId
INNER JOIN
SalesPerson E ON E.id = S.salespersonId
WHERE
s.saleDate >= '01/01/2005'
AND
s.saleDate <= '12/31/2005'
ORDER BY S.id
About Ryan Anklam
Ryan Anklam is the Chief Information Officer at Innova Creative Media, Inc. His current focus is on using ColdFusion to develop large scale hosted applications. Ryan has been developing ColdFusion applications since 1996. In addition, he is also a Microsoft Certified Professional with demonstrated skills in C# and SQL Server.

CFDJ LATEST STORIES . . .
SQL Injection attacks are one of the easiest ways to hack into a website. One recent hack, using a script from verynx.cn, involves injecting sql into a web form that then appends some JavaScript code into fields in a database that then gets executed on the client side when a user views...
Mike Neil is general manager for virtualization strategy in the Windows Server Division at Microsoft. Mike is focused on the delivery of the Windows virtualization technology, including Windows Server 2008 Hyper-V, Microsoft Hyper-V Server and Virtual PC 2007. Mike also directs the tec...
Two of the biggest launches in Rich Internet Application history took place in 2007/2008 when Adobe launched AIR 1.0 in February '08 and Microsoft launched Silverlight (September '07). At the 6th International AJAXWorld RIA Conference & Expo in October SYS-CON Events is delighted to be...
Recursion Software released a private beta version of their Voyager mobile platform, with powerful interoperability for Android, Microsoft .NET and Compact Framework (CF), all Java editions (JME CDC, JSE and JEE), and more than 15 embedded operating systems. The Voyager platform is a p...
2008 is going to be an important year for Rich Internet Applications. Most organizations are delivering or planning to deliver Rich Internet Applications; however, at the same time, most IT managers are facing a dilemma: which Rich Internet Application technology and platform to use? T...
CFDynamics, a ColdFusion web host, has renewed an agreement with SmarterTools that will allow them to pass on immediate value to their customers. When a customers signs up for a dedicated hosting account they will now receive $750 worth of features including SmarterMail, SmarterStats a...
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE