Darryl Lyons’ Blog

AJAX, ColdFusion and Web technology…

Entries Comments



Month: May, 2005

Oxygen XML Editor 6.0 released

18 May, 2005 (18:50) | Uncategorized | By: Darryl Lyons

Oxygen XML Editor 6.0 is now out, as is the companion Eclipse plugin. We use this invaluable tool at work. Seems to work fine with Eclipse 3.1 M7, although I had a small issue with the Visual XSD Editor.

DBedit plugin for Eclipse

18 May, 2005 (18:42) | Uncategorized | By: Darryl Lyons

A few people were talking about database plugins for Eclipse today, and DBEdit was mentioned. I can’t believe I haven’t found this plugin before — it’s really awesome.

DbEdit is a set of plugins for the Eclipse Platform that provide viewing, editing and designing capabilities using the JDBCTM API. It is not intended to replace any proprietary database management tool because it surely cannot beat them because the JDBCTM API has several limitations.

Currently there are the following functionalities:

  • direct table data manipulation using the Table Editor
  • editing and executing of SQl statements using the SQL Editor
  • exploring database structure using the Tables View
  • scanning tables for search patterns with Eclipse integrated database Search Support
  • exporting and importing table DDL and content using Eclipse integrated Export/Import feature
  • compare tables using the table comparison
  • explore a schema’s referential structure using the Visual Editor

http://eclipse-plugins.2y.net/eclipse/plugin_details.jsp?id=458

I got it up and running very quickly. I ended up downloading the Microsoft JDBC drivers for SQL Server. Now I don’t have to have an instance of Query Analyzer or Enterprise Manager open just to do quick lookups. The decreased memory usage of not doing so also helps!

Rich Internet Applications using BackBase

18 May, 2005 (18:34) | Uncategorized | By: Darryl Lyons

Scott Barnes sent me this link today to BackBase. BackBase is a presentation-tier technology that uses an XML language to define DHTML-based RIAs.

Backbase provides Rich Internet Application software that radically improves the usability and effectiveness of online applications, and increases developer productivity. With Backbase you can build web applications with a richer and more responsive user experience.

There are some pretty cool examples on the site, including some very “flash-like” demos.

AJAX example using jsonencode() UDF

17 May, 2005 (20:57) | Uncategorized | By: Darryl Lyons

A little while ago I put up a post about using CFWDDX to generate JavaScript code, and using dynamic script tags as a mechanism to transfer the JavaScript data from the server to the client.

I thought it would be a good idea to redo the example code using Jehiah Czebotar’s jsonencode() UDF, which creates valid lighweight JSON encoded data. If you’re still wondering what JSON is, here is a quick definition:

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate.

http://www.json.org/

The purpose of this example is to show you how easy it is to get data from the server without refreshing the page. It would even be easier if I used one of the AJAX libraries out there.

display.html

This is a sample HTML page that contains the empty table ready for population. Clicking on the “call getArtists…” link performs an asynchronous call which gets the data from ColdFusion and then populates the table.

<html>
<head>
<title>JSON Test</title>

<script src=”artists.js”></script>
</head>

<body>

<a href=”javascript:getArtists()”>Call getArtists() method — appends to table!</a>

<br/><br/>
<table id=”artistTable”>
<caption>Artists</caption>
<thead>
<tr>
<td>ID</td>
<td>Last Name</td>
<td>First Name</td>
<td>City</td>
</tr>
</thead>
</table>
<script>
getArtists();
</script>
</body>

</html>

artists.js

This JavaScript file contains methods that will dynamically create the SCRIPT tag. The src attribute of the SCRIPT tag is the getData.cfm ColdFusion template, which creates the JSON data.

The populateUI method (which populates the table with the data) is only called once the SCRIPT tag’s readyState has changed to “loaded” (e.g. the data has loaded).

The only change I had to make was the loop over the data. I now use the RECORDCOUNT for the loop condition, and reference the columns of each query row using struct of array notation.

function getDataFromServer(id, url, callback)
{

var oScript = document.getElementById(id);
var head = document.getElementsByTagName(”head”).item(0);

if (oScript)
{
// Destory object
head.removeChild(oScript);

// Create object
oScript = document.createElement(”script”);
}

else

{
// Create object
oScript = document.createElement(”script”);
}

var dtRf = new Date();

oScript.setAttribute(”src”,url + “?rf=” +dtRf.getTime());
oScript.setAttribute(”id”,id);

head.appendChild(oScript);

if (oScript.readyState!=”loaded”)
{
oScript.onreadystatechange = function()
{
if (this.readyState == “loaded”)
{
eval(callback);
oScript.onreadystatechange = null;
}
}
}
else
{
alert(’Cannot load data!’);
}

}

function getArtists()
{
getDataFromServer(”artistData”,”getData.cfm”,”populateUI()”);
}

function populateUI()
{

oTable = document.getElementById(”artistTable”);

// Loop over the data
for (var i=0; i < QARTISTS.RECORDCOUNT; i++)
{
// Create a new TR element
oTR = oTable.insertRow();

// Create a call for each element in struct
oTD = oTR.insertCell();
oTD.innerHTML = QARTISTS.DATA.ARTISTID[i];

oTD = oTR.insertCell();
oTD.innerHTML = QARTISTS.DATA.LASTNAME[i];

oTD = oTR.insertCell();
oTD.innerHTML = QARTISTS.DATA.FIRSTNAME[i];

oTD = oTR.insertCell();
oTD.innerHTML = QARTISTS.DATA.CITY[i];
}
}

getData.cfm

This a ColdFusion template that performs a query on the database, and then encodes the ColdFusion variable as JSON data. json.cfm contains the jsonencode UDF.

<cfsetting enablecfoutputonly="true">

<cfinclude template=”json.cfm” />

<cfquery datasource=”cfartgallery” name=”qData”>
SELECT *
FROM artists
ORDER BY lastname, firstname
</cfquery>

<cfoutput>QARTISTS = #jsonencode(qData)#;</cfoutput>

XML Parsers: DOM vs. SAX

16 May, 2005 (21:38) | Uncategorized | By: Darryl Lyons

I’ve been tinkering with Java lately, and I’ve been starting to playwith XML parsing. I’ll have a post up soon on comparing DOM parsing with ColdFusion (I don’t suspect too many!). I found this good article on devx, about the top-level differences between DOM and SAX specifications.

The W3C DOM specification provides a very rich and intuitive structure for housing the XML data, but can be quite resource-intensive given that the entire XML document is typically stored in memory. You can manipulate the DOM at run-time and stream the updated data as XML, or transform it to your own format if you require.

The strength of the SAX specification is that it can scan and parse gigabytes worth of XML documents without hitting resource limits, because it does not try to create the DOM representation in memory. Instead, it raises events that you can handle as you see fit. Because of this design, the SAX implementation is generally faster and requires fewer resources. On the other hand, SAX code is frequently complex, and the lack of a document representation leaves you with the challenge of manipulating, serializing, and traversing the XML document.

http://www.devx.com/xml/Article/16922/0/page/2

JSON encoder for ColdFusion

13 May, 2005 (19:19) | Uncategorized | By: Darryl Lyons

Jehiah Czebotar has just released a JSON encoder for ColdFusion, which is great news for those wanting a light-weight data interchange format (AJAX apps for instance).

CFJSON is a ColdFusion implementation of the JSON data format. JSON is a lightweight replacement for xml which translates (or serializes if you like) native datatypes into across languages. While xml is great for storing data, it does not map nicely to native data types. JSON fill’s that need. In many ways it is similar to WDDX in that it serializes data. Just with half the bloat.

http://jehiah.com/projects/cfjson/

Google Web Accelerator prefetching problems

10 May, 2005 (20:04) | Uncategorized | By: Darryl Lyons

A lot of people have discovered problems with the prefetching features in Google’s Web Accelerator. Because it pretty much “clicks” on all of the links on a page, if you have prefetching enabled when viewing a Web application, it will probably start “clicking” on the “delete item” links!

I’ve heard about this before, when people were complaining about web crawlers doing a similar thing. This though is worse, because some basic authentication isn’t really going to help!

Steve has blogged this problem, plus code enabling you to block Google Web Accelerator, as has Pete Freitag.

Others have also stated that we should just suck it, and fix our web applications to conform to the RFC, and ensure that links (e.g. GET methods) are soley used for retrieval, and use POST methods for operations such as “delete item”. I’m leaning more towards the later, but I think we all have to aware of the prefetching features in this product…

Firefox hits 50,000,000 download mark

6 May, 2005 (20:03) | Uncategorized | By: Darryl Lyons

Found a great article about Firefox reaching the 50,000,000 download mark. It goes into detail about Microsoft’s next moves, and describes some of the history behind the browser.

Also, a Spread Firefox member states how they will be distributing Firefox to 3,500,000 users in India soon.

FOP documentation is hard to find!

6 May, 2005 (19:56) | Uncategorized | By: Darryl Lyons

I’ve been mucking around with generating PDF documents on the fly with FOP. I inherited the code from one of my co-workers, just to add some styling and layout elements.

Is it just me, or is FOP one of the worst documented libraries out there? It is really, really hard to find good, practical information on how to do some pretty simple things. You would think they would have more information on the FOP site, but there really isn’t much.

Anyway, I thought I’d share some of the good resources that I managed to find:

I’ll post some of the code another day, as I think it will certainly be useful to people — how to include images, three-column layouts in headers/footers without using tables, page x of n, etc.

Phishers using keystroke loggers

6 May, 2005 (19:46) | Uncategorized | By: Darryl Lyons

Just saw this article on Slashdot about the growing trend in phishers using keystroke loggers to more easily gain access to sensitive information. This blows me away.

I’ve been frustrated about my bank using an image-based keypad for me to “type” my password in with. Sure it’s a pain in the ass, but it makes my online transactions a little safer (especially given one person’s comments).

Every time I click a “key”, the keypad moves to a random spot on the screen. It does this by calling a JavaScript method like “pressKey(’k')” — but is that really any more secure??