Tuesday, May 12, 2009

Jumping on JQuery wagon

Made a little form that's fully ajax with no reload. The most time consuming task when working with jQuery seems to be evaluating all the different plugins people made.
So I wanted to document the ones I used for this little form, so I remember and maybe someone else would benefit.

1. Autocomplete - jQuery plugin 1.0.2
2. jQuery Form Plugin
3. jQuery jSelect plugin

I am still looking for a good multiselect UI element plugin. There are some good candidates but none integrate quite so easily on first pass.

Monday, March 9, 2009

Groovy javaloader goodness

In my usual mode of trying a bunch of things at once I was rewriting some slow Coldfusion 8 code in Groovy to see if I can improve performance. And I wanted to play with Groovy.

So I set up Groovy Eclipse plug-in and dove into Groovy documentation. I needed a way to plug my Groovy .class files into my Coldfusion code. Mark Mandel has a cool javaloader thing that I haven't used yet.

The advantage of using Javaloader is you don't have to reload Coldfusion every time you recompile your Java code. There might be other advantages but that one was my main interest. It didn't work right the way because I was using Groovy not Java, but Groovy is built on top of Java so what I needed to do is to add Groovy .jar to the loader.

Groovy has multiple .jar files in it's directory. I only had to add two, depending on the code you might need to add more or all I suppose. So if you get an error at first look closely at the Java stack trace and see if there are clues as to what other .jar you might need. For example at first I only added groovy-1.6-RC-2.jar file and after running code got an error "Object Instantiation Exception. "
In the stack trace there was a line:
Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.Opcodes
That was a clue to add asm-2.2.3.jar to the fold. (Thanks Brian ;-) )

So in the end it was great. I just worked in Eclipse, switch to Java perspective change my Groovy code, click run to refresh the class file. My Coldfusion files are in CFeclipse and are side by side with Groovy files. Integration dream.

Groovy code did end up being faster by the way then Coldfusion counterpart but I did optimize some things along the way so the comparison is not exact. I am thinking of converting it to Java for the ultimate gain, but Groovy is fast enough for now.

Thursday, February 19, 2009

Coldfusion type="numeric" bug/feature

A couple of my coworkers stumbled on an interesting issue. Here are simple tests.
Thanks Jamie for additional tests and findings.

Results in this output...

NO
YES
1,3,5

It seems that type="numeric" argument in the testFUnction should fail but it doesn't.
Also isNumeric(testVal ) doesn't agree with isValid('numeric', testval) though ColdFusion documentation says it should:
"float or numeric: a numeric value; equivalent to the IsNumeric function."

Also we confirmed (thanks Brian) that this exists in ColdFusion 9 beta.

HTML parser java library, jericho

For an R&D project I needed something that would help in scraping our existing web pages, specifically pages with forms. I wanted it to be preferably a java library to easily plug into ColdFusion. After trying a few (jTidy, Cobra and two HtmlParsers) I stumbled on Jericho. http://sourceforge.net/projects/jerichohtml/. It did all I needed to do and then some. It did great parsing HTML and getting the values I was after. Projects java docs helped a lot.

There is only one .jar file (as of this writing jericho-html-2.6.jar). So put it somewhere in the CLASSPATH. To check if you put it in the right place in ColdFusion 8 administrator look in Settings Summary and see if it's listed under Java Class Path.

I didn't go as far as to write full on wrapper for it. I was after form fields so here is the code that get's what I need.


Here is the code for parseFormValues() where you can see some of the API Jericho provides in action. As I looked through this, I noticed where I collect lists values with listAppend() if the values have commas it would create a problem.
So keep it in mind if you plan to use it.
I am sure there are some other improvements that can be made since it's a first pass at this.

Note on "this" scope usage. The component this code is in, extends BaseComponent (thank you Hal Helms)
with generic (can you say "lazy" :-) ) set and get implemented with onMissingMethod. You have to use "this" for it to work inside the component.
I did find accidentally later in the project that using this (ooh cool pun) technique is slower then actually creating a setter and a getter, which kind of makes sense.

Wednesday, February 18, 2009

Railo 3 on Ubuntu 8.10

I wanted to try Railo so I installed it on Ubuntu laptop. Thanks Mark Mandel for a short blog over here http://www.compoundtheory.com/?action=displayPost&ID=393.

I didn't know what to put for mail server in Railo admin, and it kept asking for it for cfmail tag when trying to load a site. Ended up installing postfix from instructions here http://my.opera.com/Contrid/blog/show.dml/478684.

The menu for settings is a little strange, old school, and I mean old school looking. I chose "local setup" in the first menu. Use arrows to move around selection choices and Space to select. It worked in the end and "localhost" was recognized as a mail server in Railo.

Monday, February 16, 2009

Ubuntu coldfusion 8 java classpath

Quick note on Ubuntu. Once again setting up Ubuntu 8.10 with coldfusion, hard drive failed on last install. Needed to add additional java classpath location. Edited /opt/jrun4/bin/jvm.config under #JVM classpath section.