Thursday March 4, 2010 11:01 AM
Word Count: 528
Working on a project today I came across a strange issue so I thought I would get everyones opinion on it. I am not really sure if its something I am doing wrong, a bug or maybe I am just missing something. In this application I have event handling turned on.
So for nothing special and up until this point everything has been working fine. Today I am adding some ajax via everyone's favorite framework (jQuery of course) and I came across something. This is my ajax call to my remote method.
And my remote method that does a join to pull all users who have a role id equal to the argument passed.
If you were to turn event handling off this works fine but with it on I am seeing the following error.
coldfusion.runtime.TemplateProxy$InvalidRemoteAccessException: The method 'preLoad' in component D:\websites\extranetsteriscom\cfc\com\*****\*****\events\EventHandler.cfc cannot be accessed remotely.
Now in my event handler I have preLoad defined (because you have to when you implement another component) but it's not doing anything. Am I to believe that If I use event handling in my application I can't use ORM for any remote functions? I can certainly get down and write some sql but thats no fun :) Anyways, just thought I would share this and get your thoughts.
Wednesday February 17, 2010 9:34 PM
Word Count: 1399
In Part 1 I looked at why I am using Derby and in Part 2 I looked at how to create custom functions. In the final part of this series we are going to look at the actual code to create our functions.
So in the last part we took a look at writing a replace function. In my example I needed to use a replace function on a database field.
To create that function we have a class that looks like this.
Then I started thinking, what If I need to replace many instances of a string. The function above will only replace the first occurrence. No problem, as I said before we can take this opportunity to create a whole library of functions to use.
When I actually got back to writing my application I noticed another problem. What if I had to replace more than 1 item? With our current replace method I would have to do something like this.
That obviously does not make much sense so what I want to do is write a function that allows to replace multiple strings. In my case I am going to write a function that allows for a regular expression.
Now I could do something like this.
On top of that I came up with a couple other methods that I thought I could use.
I also want to take the chance to get everyone into the mode of unit testing, so please take a chance watch this public service announcement.
As you can see its pretty easy to create your own functions. On top of being extremely easy you can see its pretty powerful. I just really like being able to create methods in a familiar environment. I have attached my jar file that contains my StringUtils class but you can just as easily create your own. I hope to add some more classes + methods in the future so please give me your suggestions.
Wednesday February 17, 2010 9:10 AM
Word Count: 164
In the 1st part of this series we took a look at using Apache Derby. In the scenario we went over I came to the conclusion that I would need to write some custom functions for Apache Derby to solve my problems. In part 2 of this short series I will walk you through creating your own custom functions.
In other database management systems you have the ability to create user defined functions. You have the same option in Derby only you have to write these functions in Java. If your not a Java expert, don't worry I am not either and I can promise you this is a piece of cake. If you take a look the create function docs you will get the following explanation.
The CREATE FUNCTION statement allows you to create Java functions, which you can then use in an expression.
[More]
Tuesday February 16, 2010 12:16 PM
Word Count: 250
At work we use Oracle for most of the web applications that we create. The only exception to that would be our intranet apps. We have many small applications that are created for internal use only. Instead of having to go through our DBA's to get these Oracle schema's created I found it much easier to just use Apache Derby the embedded version. If you did not know already Derby ships with ColdFusion so it's really easy to get up and running.
Yesterday I working on application where a user could enter a number and would have to do a lookup on this number to if we had it. So if we pull the problem out and take a look at it everything seems very simple.
So far pretty simple right? A user types ABC-1234 in a text box and we do a lookup based on that. Then the requirement came across that we needed to be able to enter many at one time. No problem, we can just change that to a text area and create pass a list to our query.
[More]
Tuesday February 16, 2010 9:09 AM
Word Count: 476
A unit test can really save you some time at the end of the end. I know what your thinking because I used to think the same thing. How on earth does writing more code help save time? Unless you write perfect code I am here to tell you it just will. I thought I would share a perfect example from a class I was writing this morning. I had a very simple method that took a string and repeated it x number of times. The class looked something like this.
I had a simple unit test to make sure the repeat method was doing what it was supposed to.
My test kept failing over and over again and I could not figure out why. If you look closer you can see that I write to much ColdFusion code. I started my array loop at 0 and counted until the length of the string. This is going to throw and extra character in there. In Java this becomes much more of an issue because I have to compile my class and deploy it to my application. In ColdFusion I think its still a best practice to catch this now. This is because when you start writing code against your classes (or components) you can be confident that they will work.
Friday February 12, 2010 8:10 AM
Word Count: 250
Today is the last day to make your voice heard. Please head over and vote for your favorite topics today. I submitted a bunch with the hopes of getting at least one. I really truly do enjoy teaching others so hopefully I get the chance to do that again this year. Here are the topics I have submitted this year.
- ColdFusion 9: A new way of buiilding applications
- ColdFusion Components Introduction
- Developing Web Applications for mobile devices
- Validation in ColdFusion
- Work smarter, not harder with ColdFusion Builder Extensions
I think I have i had to vote for one or two of my topics It would look like this. First I would love to give an intro talk on components because I know them very well. I have been using components since they arrived and I think its an important discussion for beginners because they are no longer an option, they are a necessity. Next I would have to vote the way of validation. I have been working on a new validation framework for ColdFusion (which will discuss) and its been a reminder how tedious validation can get. Either way I hope to see you all at CFUnited, it really is now just one of those events I look forward to every year!
Thursday January 28, 2010 5:13 PM
Word Count: 265
I have been working on some updates to Hyrule lately and I came across a situation where I had one of those "I wish I could do this" moments. ColdFusion (along with php,asp,etc...) is a loosely typed language. This just means that you don't have to declare a data type of a variable in the language. In other languages such as Java (strongly typed) you must assign a variable a data type. I am not going to get into the pros and cons of both because you can do a quick search and find that out for yourself.
So I am working with a component that has a single function, isValid(). From the name you can probably gather that its going to evaluate some data and return a boolean. The component we are going to use as an example here is the MinValidator.cfc.
Don't worry to much about the component itself, lets focus on its task. This component accepts a struct that may look something like this.
[More]
Monday January 25, 2010 12:30 PM
Word Count: 274
With the upgrades of cfscript in ColdFusion 9 I am starting to see a lot more components written in script(Yes!). With that I am starting to see a lot of the following.
First off Its just a personal preference but attributes after the method arguments is really ugly. If you notice the output for both the component and the method has been set to false. While this was needed in tag based components this is not required in script based components. Nathan Strutz has a really good explanation of this over on Stack Overflow . Nathan's short answer is below but I would head over to the site and check out the full explanation.
cfscript does not output anything unless you explicitly call writeOutput() from it. This includes functions in cfscript as well as any cfscript code outside of a function.
This is different from CF tags' syntax, which, by default, output at least whitespace between the tags. In cfscript, any text you write will be compiled by the CFML engine. in CF tags, any text you write will be written to the output buffer and sent to browser.
Thursday January 21, 2010 8:27 PM
Word Count: 178
This is just a quick reminder to everyone about the wonderful pre conference training sessions going on at cf.Objective() this year. I know all of the speakers and can easily say that these are going to be some awesome classes. Hurry up and sign up today for one of these great training sessions.
- Building Secure CFML Applications (April 21) - Jason Dean and Pete Freitag
- Coldbox:100 Training (April 21) - Luis Majano
- Developing Applications with ColdFusion 9 Object Relational Mapping (ORM) (April 20-21) - Bob Silverberg and Mark Mandel
- Getting Started with Flex and AIR Development with the Flex SDK (April 21) - John Mason
- Mach-II and OOP from the Ground Up (April 20-21) - Kurt Weirsma, Peter Farrell and Matt Woodward
- Rapid Development with Model-Glue 3 (April 20-21) - Dan Wilson and Ezra Parker
Monday January 18, 2010 6:00 PM
Word Count: 122
I am really happy to announce that I have been selected to the Adobe Community Professional program for 2010. You can read more about it on Liz Frederick's Blog. Basically there are only 300 people worldwide selected for this program across a number of products. I am 1 of 44 ColdFusion professional's selected and could not be more excited about it. Big thanks to everyone who nominated me and an even bigger thanks to Adam Lehman who I know went to bat for me this year. I really enjoy doing my part in this awesome community and it's nice to see my work paying off! Let's all make 2010 one to remember.