Greg's Blog

helping me remember what I figure out

Busy

| Comments

Apologies again for the lack of posts, but I have been real busy at work completing another mach-ii app. So I thought I’d share a few details about this application that went live today. You won’t be able to publicly view it, so below is a screen shot (click on the image to view a larger one) for your viewing pleasure. CMA screenshot So what is it? It’s an application that allows a user to search for comparable properties within a given postcode, district, town, etc… The properties are retrieved from our databases and overlayed on a multimap image of the requested area using SVG. You can then select a series of properties (by either selecting them by clicking on them via the map or from a list). Selecting allows you to view the property?s details or you can add them to a list that you wish to examine more closely. This list can then be exported as Excel or rendered as a PDF document. The UI makes use of SVG for the rendering of the map and placement of the properties, as well as some serious dHTML for displaying the different views. All the data that drives the application is delivered using the AJAX delivery mechanism. From an implementation/developer point of view it was a whole heap of fun getting a chance to develop an “RIA” using AJAX and dHTML. Despite the debugging hell, it’s no more difficult than working with Flash Remoting and I suspect that as more work is done with AJAX the better the debugging solutions will become. The back end is all driven by CF and the framework we used, like all of our B2B apps, is Mach-ii (our consumer site uses FuseBox). The UI makes remoting calls to our app which retrieves the requested data. The data is returned in the form of XML, where after being decompressed (we compress it server side to speed up things), XSL style sheets are applied to render the output. Much of the credit for the implementation must go to Zac (where’s your blog mate?), and it’s been great working him on this project. More so because he is fellow developer who digs Mach-ii. To date this probably my most OO based app yet, but having had a few days to look back on it now, there are still a number of areas that we could improve upon. For the next point release we are looking at quite a few enhancements in terms of the back end and taking a serious look at Tartan to help us manage our Service Layer. It’s been a while since I have had so much fun developing a web app again and have had a chance to work with so many different technologies in one go. And of course CF sits at the heart of it all.

Tail | Grep

| Comments

After reading a quote on a mailing list last week about the concept behind unix tools and their focus on doing one task well and the OS allowing you to pipe several commands in one go, it dawned on me that I could do the following on log files: [code]tail -f /var/log/syslog | grep "named"[/code] So as the log fills up only items where the pattern “named” is found are displayed. Very neat! UPDATE Thanks to some of the comments, here’s a way to colour code the output (hopefully this will render better than the comment output) [code]tail -f /var/log/syslog | grep "named" --color[/code]

maxEvents

| Comments

maxEvents is used in the mach-ii framework primarily to help you not get into an infinite loop. Of course limiting the number of events can also land you in trouble as some request may require more events than currently set. Determining this number is something that you will need to figure out yourself. Ben Edwards suggests that 50 or more events is fine, however he did recommend against disabling it. For the record you can disable the maxEvents by assigning it a negative number.

Cycling Through Your History

| Comments

I quite often find myself cycling through the history of commands I have typed in the console window and there can be quite a few commands stored there. John, part time philosopher and all round good bloke and extraordinary at all things computing related, stopped me from monkeying around on the keyboard and showed me the following command that stopped me from having kittens when it came to finding that all important and elusive command: [code]history | grep "pattern"[/code] For example while re-building qmail I was looking for the last make statement: [code]host:/tmp/qmail/maildrop-1.6.3# history | grep "make" 511 make man && make setup check 514 make man && make setup check 517 make cert 520 make && make setup check 528 make && make install 536 make && make install-strip 541 make && make install-strip && make install-man 547 history | grep "make"[/code] Then you can do !541 (“!” is pronounced bang) and this will execute: “make && make install-strip && make install-man”. Sometimes working with *nix systems is just so handy and it’s another feather in my cap! Oh and John see I managed to get kittens, monkeys and hats into a post!

CSS Organisation

| Comments

A few week old now, but Doug over at Stop Design has come up with yet another invaluable little trick: when working with large style sheets it can be quite a lot of work to scroll through it in order to locate a certain declaration. His tip, label your sections and prefix the label with “=” like such: [css]/* MISC: =Lists ----------------------------------------------- */[/css] Since “=” is not used in CSS, doing a search for =List will quickly get you to where you need to be. And while you are over at his site, why not read up on his latest collaborative project with Happy Cog and Jeffrey Zeldman: Cap Gemini a glorious CSS/xHTML redesign!

Koders

| Comments

I was just reading through this mornings SD times newsletter and there was an interesting link to a new (-ish, it was released in May) search engine called Koders, which returns results from open source projects. It even has a little Mozilla and Eclipse search plugin. Now there is even less of a reason to re-invent the wheel.

Flash URL Trimming

| Comments

This was slightly annoying: I was finishing up an Oracle portal application that was making use of a little flash client to pull data from a few sources. If the data was not comprehensive enough we also provided a Single Sign On links to the applications in question so that user could dig deeper. For one reason or another the URLs for the Portal server had been changed which meant I had to go round and re-compile the various flash movies with the updated URLs. So we went from “http://short:7777/pls/portal/” to “http://yourreallylong.domainname.com/pls/portal/”. This is turn meant that the SSO query strings became even longer after the server side re-direct, see below: [code]http://yourreallylong.domainname.com/pls/orasso/ORASSO.wwsso_app_admin.fapp_process_login?p_app_id=A9EA58560B278E1CE1C3B5CD64C6D9E[/code] And all of a sudden the SSO links no longer worked. What was happening was that “p_app_id” was being trimmed by 2 characters (so instead of passing 129 chars to the browser only 127 were) by the Flash client. Thankfully we didn’t need the fully qualified domain name so as a quick work around I could simply drop “domainname.com” and it all worked again. After this I did a quick google search and here is the Technote on the topic and a suggested work around.

Quantum Bookmarks

| Comments

Now that I have my mobile development environment set up I thought I’d take a few moments to make a note on how you create bookmarks to your databases when using the Eclipse plugin Quantum. First off make sure you are in the Quantum perspective (Window > Open Perspective > Other > Quantum). In the Database Bookmark pane right click and select New Bookmark. For MySQL I decided to use the driver provided by the people behind MySQL (you can download it here) since this is the one I use in conjunction with BlueDragon. If this is the first time you are setting up a bookmark/connection for a MySQL database you’ll need to add the driver first (Add Driver > Add External Jar > Select a class name [com.mysql.jdbc.Driver] > Type = MySQL > Finish). Next make sure the MySQL driver is selected and click Next. Simply specify the normal details you would when say creating a datasource (username, password, hostname, port and database name) and once you click on Finish you are done! For Oracle databases though I initially struggled a little, because I had opted to use the driver included with JRun/CFMX. By using the ones that came with BlueDragon the problems went away. So as with MySQL add a new driver and use the BD one (class name: oracle.jdbc.driver.OracleDriver) and after clicking next simply provide the information you are prompted for as per the MySQL instructions.

Populating a Drop Down Box From a Comma Delimited Field

| Comments

Occasionally you’ll come across database fields that contains a list of keywords that are comma delimited. One instance would be for storing the style of a certain product. Take shoe as an example, you can have a trainer, walking, formal or work style for said shoe. These different styles in our case were stored in one field in database. However when it came to building the front end of the shopping cart we needed to allow the user to choose a specific style for said shoe. In the following I’ll be explaining how populate a drop down box from a comma list of items stored in a database.Step 1, get the items of interest. Here we right a basic query that retrieves the contents of the field we wish to display, in our case the style of a shoe. The code below shows you how to do this: [code] select table.style from table where item = ‘shoe’ [/code] Here we select the content of a field called style in a table called table where the item value is equal to ’shoe’. Next we define a variable and store the results of aforementioned query in that variable. [code] [/code] As result of this the variable keywords contains the following information (based on the above example: trainer, walking, formal, work. Now we need to extract that information and put into a drop down menu. To this end we will have to loop over that variable and display each and every item in an field. Thankfully allows you to specify a delimiter and in our case it would be a ‘,’. So the entire Cold Fusion code would look something like this: [code] [/code] And there you go, you know have broken down a comma delimited field into a drop down menu based on the content of a field in your database.