Tag Archives: web application

Why Coldfusion / CFML has its place and is worth to learn it

I actually never indulge in conversations why one programming language is better then another, because what is right to you, does not automatically mean, it is right for someone else. So, for me ColdFusion, or as we call the language itself – CFML, works very well.

Nevertheless, in this post I like to clear up some confusion that has been around. I can see where the confusion comes from as Coldfusion has gone from Allaire to Macromedia and is now “in the hands” of Adobe.

In any case, here are some reasons why CFML is still worth for you to learn.

  • CFML is open source and yes you can use it for free. I guess, many people are put off by the fact that Coldfusion has had a big price tag on it in the past. True, given the nature of PHP, Java, Phyton, Ruby, etc. being free, there was actually no reason to shell out your hard earned buck for some application server and on top of it even learn the language. Thanks to the short sighted business decisions of Macromedia and now Adobe or shall we say with the greedy money making mentality of its management, Coldfusion has been faced with a drainage of developers.
    Fortunately, this has all changed with the advent of OpenBD – the first real open source CFML server, followed shortly by Railo, another popular open source CFML server. In other words, to learn CFML and to deploy your applications, is now free and free to be.
  • Write less code. Compared to PHP, Java, C++, even Ruby and Python – CFML allows you to write the same program with much much fewer lines of code. Why would you want spend your precious time writing more code when you can do it for less? As a matter of fact, you can write your application in CFML so efficiently, that the same application written by you alone would probably need a team with Java, Ruby, etc. This is a proven fact.
  • Well designed. The CFML language is well designed and many required functions already exists for you to use. There is no need to write a wrapper for a email sending function. I mean, you don’t even need a framework, to achieve a simple tag like “<cfmail…>”. There is no obnoxious, framework to learn or write functions for this. Compare this to Java, PHP, Ruby, etc. you are very well off with CFML. (again all without a framework)
  • Build web applications fast. Due to the nature of writing less code with CFML and with the built in function, you will be writing your next web application in weeks, instead of months. On top of that, you will have a full scalable enterprise model on your hand to scale when your startup takes off. Heard about the stories of PHP web apps, that had to be converted to xyz language just to scope with the traffic. Again, if you would deploy your web application with CFML and OpenBD, you can deploy on any Java application server (Tomcat, JBoss, Websphere, etc.), connect to any database (MongoDB, H2, Oracle, MySQL, MS SQL, DB2, you name it…) and have your cluster, load balancing, caching setup done.

If you are in for writing less code and building your next web application the fast way, then I simply urge you to give CFML a try. I’m certain that you will get your project done in half the time then in another language. There is simply nothing to loose for you!

 

The quest for the perfect Gmail experience on the Mac desktop and on the iPhone

Given gMail has one of the best web application interfaces (for its usage) and can sit happy in your browser tab, it is after all still a web application and can not interact with your local address book, offers no drag and drop possibility and desktop notifications.

Furthermore, Gmail offers some really useful features like threaded conversation view, saving of chats, starred items and archives. Features that anyone who has used Gmail for more then one day has come to love and cherish. Since, those functions are just so useful many are just using Gmail in the browser, after all it is free and it works.

Still, I set out for a quest to find a desktop client and an iPhone app for gMail for the obvious reasons mentioned above and… …to say upfront, I found (for me) the perfect Gmail experience on the Mac and on the iPhone. So, read on…

Synching
We as Mac users like our iCal and our Address Book. They might not be the perfect solutions, but to be honest, they are the best we have and they come with MacOS X and are tightly integrated with the system. Thought, Apple made some improvements to iCal (adding WebDAV) and subscribing to other calendars it does not come close to experiences that some have with Outlook and Exchange server. Let’s not even talk about the Address Book which is somehow closed in itself (yes, I know you can lookup LDAP, but does a private person have LDAP installed?). What we (I) really want is to have a easy synchronization of my Calendar (iCal) and my addresses (Address Book) with Gmail. It is not too much to ask, right?

The desire to do so, is fortunately not only mine, but also that of the developers of SpanningSync. In short, SpanningSync allows you to sync your address book and calendar(s) (yes, more then one) with your GMail contact/calendars. Best of it all, you don’t have to do anything at all to make it work, simply install it, set it up once and forget it. From then on SpanningSync, syncs everything in the background for you.

For me, not one thought crossed my mind not to get it. They offer an annual license or a onetime license.

iPhone & gMail

Besides browsing to the mobile gMail site within Safari and then save it as a book mark site (which then appears as a custom app on the iPhone) there are two gMail applications, one is called iGmail and the other Mailroom.

Honestly, I have been using iGmail for some time and even slashed out $5 for having it work with my Google App account. But recently I experienced random lockouts, as such that I could not login anymore (even after restarting the phone) and once I was able to re-login I experienced random crashes. Another thing is that on slow connections (like on EDGE) the application did not work at all. Obviously, I was looking for an alternative.

Today, Mailroom had gotten the top spot on my iPhone. Mailroom is by far the best gMail application and works every time I have to use it, be it on a slow network or not. Mailroom does even more then the “normal” gMail mobile site. Some of the things are;

  • Multiple Accounts
  • Threaded Messages
  • Using Local Address Book
  • Offline Support

Personally, I don’t regret for once second that I bought Mailroom. It works every time and does what it promises.

Desktop & gMail

Of course, you can have your Apple Mail set up with gMail over IMAP (recommended) or POP3, but for me Apple Mail does not work so well. I like the gMail interface, but still want the desktop feeling and the convenience of attaching any document by drag/drop. The only application that offers me all that is Mailplane. I can’t say anything else, then that Mailplane does all the things you are accustomed to from a desktop application and some more. That and the user interface from gMail makes it a clear “must have” for any serious gMail user.

Some of the benefits of using Mailplane are;

  • Having notification (Growl)
  • Drag & Drop attachments
  • Having different account and switch to them on the fly
  • Individual formated signatures for each account
  • Access to Address Book
  • Create screen shots within Mailplane
  • etc.

The Conclusion

Having a perfect workflow in sync with gMail, MacOS X and iPhone is something that can easily be achieved with the outlined tools above. For me, my current set up works flawlessly for many months now and supports me 100% in my work. In short, I use SpanningSync for having my calendar and address book in sync with gMail, iCal and Address Book. On my iPhone I got Mailroom and on MacOS X I use Mailplane.

ImageMagick and Ghostscript playing nice with web applications

I had to spent way too much time the last time to set up ImageMagick and Ghostscript together that I simply jump right in so you don’t have to waste time on this, like I did.

Creating thumbnails and images from a PDF is one of the most used features within Razuna. But the other day, when we run the normal convert command we were faced with an error message within our web application of:

Error: Uncaught exception ‘ImagickException’ with message ‘Postscript delegate failed....: No such file or directory

Of course, the first thing I did was to see if we have a error in the shell. Strangely, there was NO error when running the same command in the shell! Needless to say, I spent many hours looking for a solution, trying out different things from reinstalling ImageMagick and Ghostscript to looking all over the web for an answer.

In the end, it boiled down to that web applications (be it CFML, PHP, etc.), are looking for a different executable path then when you run command from the shell. Since Ghostscript installed the executable in the “/usr/local/bin/gs” path the web application could not find it. So the solution to “hours of pain” was to simply create a symbolic link to the “gs” library in the “/usr/bin” directory with:

ln -s /usr/local/bin/gs /usr/bin/gs

Hope this helps the next seeker!

SQL Paging with Oracle, MySQL and MS SQL

I have to admit, I love databases. To hold data in a central place and be able to hook up any application from wherever you are to it, is just convenient to say the least. But there are moments I wish that vendors would “follow” a standard. I guess, when it came down to paging, every vendor thought his way of doing it is the best. No wonder, paging is the one SQL syntax that differs the most. Thus I dedicate, this post to paging and outlining the difference, meaning the solution to achieve it with Oracle, MySQL and MS SQL.

Paging with Oracle

Oracle knows of the internal column “ROWNUM”. Thus with “rownum” we can page trough the records, but have to do this with subselects. Look at the example;

SELECT rn, columns
   FROM (
  SELECT ROWNUM AS rn, columns
    FROM (
      SELECT columns
      FROM table
      WHERE id = 1
      AND something = 2
      ORDER BY columns
      )
    WHERE ROWNUM <= 10
  )
WHERE rn > 0

In this example we select the first 10 records, if you want to select the next 10 records then you will need to increase the values for “ROWNUM” with 20 and for “rn” to 10.

Paging with MySQL

There is one thing I like MySQL, that is the “LIMIT” clause. Not only can you limit how many records to retrieve, but can also add a offset to the limit clause. Thus we can do very elegant paging with “LIMIT offset, number”. Again, we limit the query below to return us 10 records:

SELECT columns
FROM table
WHERE id = 1
AND something = 2
ORDER BY columns
LIMIT 0, 10

Now, this will return the first 10 records. So, what if we want to do a paging here? Actually, quite easy, all we have to do is to increase the offset by one. It is important to know, that the offset start with a “0″ (think of it as the FIRST page), thus if we want to retrieve the next 10 records we use the limit with “LIMIT 1, 10″. This will give us the next 10 records. Elegant, no?

Paging with MS SQL

Now paging with MS SQL took me some time to figure out, since some said that MS SQL know of “rownumber” as well, but honestly, I couldn’t get anything to work with it. So the most easy method to do paging in MS SQL is to use the TOP syntax combined with a NOT IN subselect. Makes sense, right? Here is the example;

SELECT TOP 10 columns
FROM table
WHERE xxxx
AND id NOT IN (
  SELECT TOP 0 id
  FROM table
  WHERE xxxx
  )

As in the Oracle example above, if you would like to retrieve the next 10 records you would have to increase the TOP values by 10 records, meaning the FIRST TOP would have a value of 20 and the inner select TOP a value of 10.

So here you have it. How paging works for Oracle, MySQL and MS SQL.

Tomcat and directories

I run into a nasty issue the other day with “alike” directories in my web application.

That is, I had a copy of a “WEB-INF” directory called “WEB-INF–”. While my web application did not bother with copy of the WEB-INF directory, Tomcat threw all kinds of errors in the catalina.out log file. Also, I had some issues with Tomcat restarting and strange Java error messages, like:

Java.lang.NullPointerException
com.nary.util.Localization.convertCharSetToCharEncoding(Unknown Source)
com.naryx.tagfusion.cfm.engine.cfEngine.getDefaultEncoding(Unknown Source)
com.naryx.tagfusion.cfm.engine.cfFormData.<init>(Unknown Source)
com.naryx.tagfusion.cfm.engine.cfFormData.<init>(Unknown Source)
com.naryx.tagfusion.cfm.engine.variableStore.<init>(Unknown Source)
com.naryx.tagfusion.cfm.engine.cfSession.<init>(Unknown Source)
com.naryx.tagfusion.cfm.engine.cfEngine.service(Unknown Source)
com.naryx.tagfusion.cfm.cfServlet.service(Unknown Source)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

After browsing the log files, I saw that Tomcat tried to read the directory and threw a bunch of critical errors while reading those copied directories. I guess, Tomcat got totally confused and tried to overload libraries.

Lesson learned; Never have any copy of the WEB-INF folder within the web application again.

How to add a custom filter to a Spry text field validation

I have to say that I love the Adobe Spry Javascript framework. It is easy to use and simply just works. For most situations it comes with “widgets” for just about everything you need in your Ajax enabled web application.

One of my favorite widgets is the Text Validation one. With it you are able to validate just about everything the user enters and you will have full control of the input, even the pattern of the input.

But what about if you need a custom validation? According to the documentation you can use the “custom” parameter with a “pattern”. But if you use it, you actually apply a “pattern”, meaning applying a pattern of “pattern: “bbb” only allows the user to enter 3 alphabetical characters, but nothing more. Usually you want to have the user enter only alphabetical characters and not limiting the amount of chars.

In order to achieve this, you have the undocumented parameter called “characterMasking”! “characterMasking” combined with “usecharacterMasking: true” allows you to pass Regular Expressions to the text field you want to validate within the Spry syntax. Powerful stuff. It is beyond me, why Adobe has not updated their documentation on this. In any case, here is a example:

Say you want to allow only alphabetical character in lowercase and nothing else, you would use a syntax of;

var custom = new Spry.Widget.ValidationTextField(“myfield”,”custom”, {isRequired:true, hint:’some hint’, characterMasking: /[a-z]/, useCharacterMasking:true, validateOn:["blur", "change"]});

Would you like to only enable digits and spaces?

var sd = new Spry.Widget.ValidationTextField(“subdomain”,”custom”, {isRequired:true, hint:’Desired Subdomain’, characterMasking: /[\d\s]/, useCharacterMasking:true, validateOn:["blur", "change"]});

I guess you get the point. Combined with Regular Expression the Spry Text Validation Widget just entered into a new level of productivity.