Showing posts with label coldfusion. Show all posts
Showing posts with label coldfusion. Show all posts

Saturday, October 20, 2012

Coldfusion ORM many-to-many on same entity

Well, there is a new job, as of 08/01/2012 and new excitement. Also new problems to solve and code. Worked on creating ColdFusion 9 ORM settings for many-to-many relationship to the same entity. Here is a result: I used some of the code from Bob Silverbergs blog here. Thanks Bob.

Tuesday, May 17, 2011

cf.Objective() impressions

Back from cf.objective() conference.
I was going in a little burned out but as soon as I saw some familiar faces at the bar I new it's going to be great. And it didn't disappoint.

Here is a quick recap of the sessions and subjects that stood out and got me excited. These sessions inspired me to evaluate my current development process, to try new tools and expand my knowledge.

In no particular order:

Progressive enhancement - Barney Boisvert
Barney made a great case for this technique. The basic idea is to develop HTML and CFML to lowest common denominator i.e no JavaScript or CSS (HTML should be prepared for CSS though) and then progressively enhance with bells and whistles. In a lot of cases the basic is enough and it naturally degrades.

Jasmine, JsTestDriver, Angular -Elliott Sprehn
Very excited to try these tools. Finally a way to develop JavaScript with tests and an MVC. What I really liked is that using methods shown by Elliott one starts to develop web application from the same point one starts thinking about it - user interactions and page content. I can't wait to try Angular JavaScript framework.

NoSQL databases - Peter Bell, Mark Drew and a BOF - great sessions on NoSQL databases and specifically CouchBase.
The BOF had great attendance and Matt Woodward did a good job moderating the discussion. Also need to look at MongoDB. A lot of ideas were presented on what to use these document databases for, but one needs to carefully evaluate the needs of an application.

Mylyn plugin for Eclipse. I don't know why I never used this, but every point in the session applied to my work environment. So needless to say I installed Mylyn immediately following the presentation.


One very exciting project is cfselenium from Bob Silverberg. I didn't get to attend his session on Selenium but it's posted on his blog. CFSelenium allows you to write Selenium tests in ColdFusion and run them in MXUnit. Great thing about being at the conference is sometimes you can try the tools right the way and if something is not working ask the author. I did just that by "accidentally" sitting next to Bob at lunch.

Continuous Integration with Jenkins and ORM Zen (best session name by the way) by Marc Esher helped me answer some parts of the process where I got confused and stuck before. These were very timely since I just rewrote a small app I have with ColdFusion 9 ORM and set up Jenkins locally to run build with tests, and also while at the conference converted Selenium tests into CFSelenium so all these were very hands on and super practical for me.

There were two re-factoring sessions by Emily Christiansen Making Legacy Code Testable got rave reviews from my co-workers that attended and made wish I did too. I did attend Getting To Know Anti-patterns talk which was great and timely because who doesn't have legacy code they wish they could improve. Made me want to read a book on anti-patterns.

This year cf.Objective() introduced "Deep Dive" type sessions, where a speaker is given two hours to explore his/her topic and go, you know, deeper.
I attended Multi-Tenant, Multi-Lingual Web Platforms - Software as a Service and it was as long and deep as it sounds. The jury is still out on how effective these longer sessions are. The presenter Sean Corfield is very good but it's a lot of information. Thankfully the presentation is posted on his blog so I am planning to review it again. I think same goes for his Functional Programming/ Clojure talk. It made me want to try Clojure and in fact I have started on that road but it's such a change in thinking that one really needs to press on before "fog" lifts. Here is good intro to Clojure that Sean tweeted about and it got me going.

I really didn't have any negative impressions at all at the conference other then staying in the hotel across the street because I forgot to book Hyatt in time.

Content was wide and deep.
Location enjoyable and convenient.
Food tasty and filling.
And people ... ah the people is what really made it great.
I feel like I still have enough impressions for few more blogs thanks to all the organizers, speakers and attendees.

So really hope to make it again next year.

Thursday, April 22, 2010

cf.Objective(0) - Keynote

Terry Ryan - Adobe

ColdFusion 9 is certainty seems to be exiting release.

EULA changed - only pay for production license.
cloud license - standard 1 cloud license, enterprise 10 cloud licenses.

CF Builder - Eclipse under the hood, code assist, code insight, sql insight.
CFBuilder Extensions. Extend-able with coldfusion. Instant code review extension Terry wrote because of working remote.

Apptacular code generator. Seems very sleek.
Flashbuilder with CF builder and Catalyst.
CF 9.01 update is coming soon - array looping, scriptable components dbinfo and more.

cf.Objective(1) - Easy and Flexible Validations for Objects

Arrived at cf.objective() with not much delays. All the usual suspects are here. Looking forward to the sessions. I will try to blog about every session I go to.

First one is Easy and Flexible Validations for Objects - Bob Silverberg.

Why do validation..? duh.. :-)

Bob presented his validation framework - ValidateThis.
It combines the definition of form field into one very flexible xml document.
Framework can then generates both client and server validation and returns structured results.

The system works by passing instantiated bean into frameworks facade. There are plans are to make it take a structure of data.

ValidateThis supports internationalization.

complex dependencies between one fields value and validation of another is also available.

http://www.validatethis.org
http://groups.google.com/validatethis
http://guthub.com/bobsilverberg/validatethis

Wednesday, March 17, 2010

Coldfusion struct sort order

Hello my blog. We haven't spoken for a while.
So feel the need to blog something even though it's just a link to another blog that has link to another blog ... :-).

Anyway needed to figure out why my struct is not outputing in the order the values were created.

This blog post has the answer.

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

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.

Thursday, October 30, 2008

Using ehCache

I needed to speed up the loading time of some dynamic pages. So I decided to try some kind of caching solution. A coworker sent me this link to Andrew Powell's blog post. I gave his facade a try it seems to be working great.

I made mach-ii plugin to manage the keys for cached content. Plugin has 2 parameters,
first is a name of event arg that has content to store in cache, second is an event to announce if there is cached content.

Here is most of the code for the plugin with makeCacheKey() method omitted because it would be different for others, the main thing is that it returns a string with a key or empty string.

Wednesday, August 20, 2008

ColdFusion development on Ubuntu 8.04 - part 2

Picking up where I left off with setting up ColdFusion development on ubuntu. I decided to give VirtualBox a try. it's better to download one from the site. I used the binaries download link, not the OSE version. Install is pretty smooth I just double-clicked on the file and debian installer came up.

After that I setup and installed Windows XP virtual box. Had to do it twice since first time didn't give it enough space. Second time gave it 30G.


Installed MSSQL 2005 and restored a database backup.

So far so good. So now I need to connect to this database from host ubuntu (the windows xp in virtual box is referred to as "guest").

The best instructions that worked actually were in the VirtualBox help files.


I added another network adapter to my virtual XP and made that one HIF:


Run ipconfig in virtual XP to find the IP and that's the IP I used in ColdFusion admin to connect.
Remember to enable TCP/IP in SQL for connection:
Start-Programs-MS SQL Server 2005-Configuration Tools - SQL Server Configuration Manager - SQL 2005 Network Configuration - Protocols for MSSQLSERVER

Now I might need to make the IP permanent somehow, but I am very pleased that it works the way it is so far

Saturday, August 16, 2008

ColdFusion development on Ubuntu 8.04

In an effort to have our code tested on linux platform I once again embarked on a quest to setup developing platform on Ubuntu. Last time I had it all (except VPN) working but the hard drive failed.

Now with new laptop I am ready to go at it again. The laptop is Lenovo T60. Here is a list of applications:

Ubuntu 8.04 LTS Desktop edition http://www.ubuntu.com
Downloaded and burned on CD, then boot from CD and choose install Ubuntu. Chose second choice for predefined partitioning.

Eclipse http://www.eclipse.org/downloads/ Java developers edition
Download and and untar somewhere. I just created eclipse directory in home directory. Added a link to "eclipse" executable to start it up. Also eclipse required Java so I installed that through Add/Remove... application in Applications menu. I installed openJDK 6 and Java Runtime 6, not sure which is required or both.

Once Eclipse started working installed following plugins:
CFEclipse http://www.cfeclipse.org/update
subclipse http://subclipse.tigris.org/update_1.4.x
MXUnit http://mxunit.org/update

Apache web server
For apache I chose to install LAMP, the instructions are found here:http://ubuntuguide.org/wiki/Ubuntu:Hardy#Install_a_LAMP_server_on_a_Desktop
no problems here

ColdFuison 8 developers version
Download ColdFusion from here http://www.adobe.com/cfusion/tdrc/index.cfm?product=coldfusion
Pretty good instructions here: http://www.redelijkheid.com/?p=322
The start up script is not created since Ubuntu is not supported platform and in the script that creates the startup scripts it's checking for linux flavor. I added couple of custom application launchers to top bar for starting and stopping ColdFusion. ColdFUsion needs to be started under sudo (or at least it appears that way) so I chose Application in Terminal so that I can type in sudo password when needed. I am sure there is a better way but I didn't want ColdFusion started on start up, and I wanted to be able to restart easily.



Spark IM client
http://www.igniterealtime.org/downloads/index.jsp
This is a IM that we use at work. Like eclipse I just untar into folder and made application launcher to Spark executable.

VPN client or module or something
This was very simple and so far seems to be working fine. Installed VPN Connection Manager through Add/Remove... menu and VPN Connections option appeared in the menu when network connection is clicked. Just configured connection to our work VPN and so far seems to be working. I was able to get to internal websites and connect to internal database.

So far everything seems to be working pretty well.
We use MSSQL 2005 so if I want it localy I am not sure what to do yet.

Saturday, August 2, 2008

Strange behavior, objectid() method in component.cfc

So I was working on something OOP :-). And I am trying to use Hal Hellms BaseComponent.cfc that all CFCs that don't extend anything should extend. For the purpose of this post I reduced it to two methods:

The way I was using it is I included it into ColdFusion component.cfc that all CFCs extend by default:

So I also make test CFC and a cfm page:


When I run cfm file and expend the dump output I see following:



As you can see the objectid() method is missing.

Now I remove the include from component.cfc and make my test component extend BaseComponent

Run cfm again and get following:


Now objectid() method is seen in the dump.

Wednesday, July 23, 2008

Populate coldfusion bean from query

I thought of a nice way to populate coldfusion beans from a query. It might be obvious, but we have code all over in our mach-ii application that explicitly calls setters on a bean after query. So following method got added to BaseComponent.cfc (thanks Hal Helms). It's not checking anything so the burden is on query to have the right data.


If you use generic setter the line:

can be replaced with:


So this allows me to do something like this: