Viewing by month: April 2007

Apr 19 2007

Silverlight: Fire and Motion

Every year or two, an event happens that makes me very glad I'm not a Microsoft shop. These same events also make me ask another question: Why do any business leaders allow their CTOs and technical managers to follow the Microsoft Web development roadmap now that it's become a large-scale implementation of the Hewlett-Packard model?

Read more...

4 comments - Posted by Joe Rinehart at 11:45 AM - Categories: RIA Platforms | Causing Trouble

Apr 16 2007

Silverlight: Microsoft Vaporware Video

Microsoft "Silverlight" popped up this morning, a "cross-browser, cross-platform plug-in for delivering the next generation of media experiences and rich interactive applications (RIAs) for the Web."

Read more...

10 comments - Posted by Joe Rinehart at 8:24 AM - Categories: Causing Trouble

Apr 4 2007

Faster UUID Creation in ColdFusion

A few apps I've worked on have needed to ID entities by UUID for a variety of reasons. One in particular creates large numbers of entities.

This can be a bit problematic under load - the UUID algorithm built into ColdFusion MX (through version 7, at least) is notoriously slow. Hopefully, Scorpio will speed it up - I believe java.util.UUID is part of Java 5.

Until then, I've found that an external UUID generator called JUG (Java UUID Generator) works great.

A sample test of 1000 UUID creations (run wonderfully unscientifically) results in the following:

JUG: 9ms

CreateUUID(): 1235ms

Bit of a speedup.

JUG also gives the option of using different twists on the UUID algorithm, as well as alternate randum number generators.

Here's an example use:

<cfset uuidGen = createObject("java", "org.safehaus.uuid.UUIDGenerator").getInstance() />
<cfset uuidGen.generateTimeBasedUUID() />

Not too bad, eh?

Happy faster UUIDing!

13 comments - Posted by Joe Rinehart at 7:28 AM - Categories: ColdFusion MX

Apr 3 2007

Model-Glue: Rendering Excel, E-mail, and alternate formats

Ray Camden posted a question to the Model-Glue list earlier today that was related to how he could use Model-Glue to render an Excel spreadsheet (via the HTML table -> <cfcontent> method) and access the rendered HTML from within a controller.

It's pretty straightforward to do the rendering with a simple view that contains a <cfcontent> tag, but he threw in a twist: he needed to access the rendered content and save it in a log.

Ok, that's a bit harder. Model-Glue processes all event-handlers in a given request before it starts to render views. Basically, there's no way for a controller to ask for the contents of a view, because they haven't been rendered yet.

Why? By not letting you render a view for the purposes of creating an HTML e-mail or XLS spreadsheet, Model-Glue is encouraging you to create this functionality in a way that's re-usable outside of Model-Glue. The whole "separation of logic from presentation" thing.

A solution I'd use for Ray's situation follows:

  1. Create a CFC dedicated to rendering data in a specific format. In this case, ExcelDataRenderer would have a method like renderReportData(data:Query) that returned an (html) string suitable for sending back to the browser as a spreadsheet.
  2. Set up an event such as the following:

    <event-handler name="downloadAsExcel">
    <broadcasts>
    <message name="getDataForReport" />
    <message name="renderReportDataAsExcel" />
    <message name="logExcelDownload" />
    </broadcasts>
    <views>
    <include template="excelContent.cfm" />
    </views>
    </event-handler>

  3. A message listener for getDataForReport grabs the report data and places it into an event value.
  4. A message listener for renderReportDataAsExcel uses our ExcelDataRenderer to render the data and place the result into an event value:

    <cfset var reportData = arguments.event.getValue("reportData") />
    <cfset var renderedReport = variables.reportRenderer.renderReportdata(reportData) />
    <cfset arguments.event.setValue("excelContent", renderedReport) />
  5. A message listener for logExcelDownload then logs the fact that the user is downloading this report, saving the excelContent event value's content in the log.
  6. Last, the view just grabs whatever value is called "excelContent" and displays it as the appropriate content type.
  7. 1 comments - Posted by Joe Rinehart at 12:00 AM - Categories: Model-Glue