I just wanted to list some of my favourite Java shortcuts that I like to use when using ColdFusion
java.lang.String.length() - Yes I could do this with Len() from cf, but typing myString.length()seems to be so much easier and faster for me.
java.lang.String.getBytes() - a useful way of working out how many bytes in a string. This can be interesting to use to check approximatley how much memory you are using when storing long strings in a shared scope.
java.lang.reflect.Array - The man when it comes to dealing with Java native arrays.
java.util.Date.before() and .after() - Yes, I can use dateCompare, but I simply find if(myDateOne.after(myDateTwo)) {..} so much easier to read (and all CF date objects are Java date objects).
java.util.Vector.addAll() - Since all CF arrays are vector, this is a easy way of adding an entire array into another without having to manually enter every single item. i.e.
<cfscript>
a = arrayNew(1);
a[1] = "1";
a[2] = "2";
a[3] = "3";
b = ArrayNew(1);
b.addAll(a);
</cfscript>
I think that's all the ones I usually use at the moment - what other Java snippets do you use to save yourself time?
Totally kicking myself over this one...
Found a bug in the new updater for CFMX 6.1 (ColdFusion Server Developer 6,1,0,83762 ).
Try the following code:
Hello.cfc
<cfcomponent>
<cffunction name="hello" access="public" returntype="string" output="false">
<cfreturn "hello">
</cffunction>
</cfcomponent>
Test.cfm
<cfscript>
obj = createObject("component", "hello");
dObj = duplicate(obj);
</cfscript>
<cfinvoke component="#dObj#" method="hello" returnvariable="hello">
Error Returned:
The <b>component</b> attribute in <b>cfinvoke</b> tag has invalid value. |
| The <b>component</b> attribute can either be a string (component name) or a component object |
This did not occur prior to the updater being put into place.
Unless there is now a new way to dynamic method invocation, this could provide some real issues.
I have another bug that I have yet to track down that seems to be linked to a similar duplicate issue and inheritence, but I have yet to track that one down fully.
I couldn't find anywhere to submit this as a bug to MM, but I know the guys there read this, so I'm sure one of them will pick it up.
Much thanks to Rob from CFEclipse for pointing this out for me.
Eclipse by default does not support Unicode / UTF-8.
Turning it on, is very easy if you know where it is.
Goto:
Window > Preferences > Workbench > Editors
At the bottom of that screen you can see 'Text file encoding'. Just choose the relevent one (choices range from US-ASCII to UTF-8), click the one you want, and presto, away you go.
Then just reopen the UTF-8 file you had, and presto - Unicode Support!
I'm so excited, I have to share.
My beautiful and incredible better half agreed to marry me over the weekend, and quite frankly I couldn't be happier.
She is the light of my life, and every day I am thankful she decided to fall in love with me. :o)
Frameworks have been a hot topic of discussion around my peers at work of late, and I was wondering what sort of frameworks the wider community was using.
Personally I tend to utilise a custom/personal framework that I have slowly developed over the past few years. I've tended to shy away from using something standard such as Fusebox or Mach II, not because they are bad products (I've honestly never looked at them properly to give a good evaluation) but simply because (a) I like knowing how the internals of my system work and (b) I find framework development really interesting (and often the most interesting part of application development).
That being said, if I'm doing Java development, I'll tend to use something like Struts or the like, simply because I find I need something like that to get work done in J2EE (being it is rather low level). That may also just be because I've not had a huge chance to get my hands deep down into the bowels of what really makes J2EE tick, and therefore haven't had the time to make up something of my own.
So, do you use a custom framework? if so, why so? or have you started developing with something like Fusebox or Mach II, and if so, why so?
Was searching for a way to do ordering within CONNECT BY clauses in Oracle PL/SQL, and came across this great article on all sorts of aspects of Hierarchical data support within Oracle 9i.
Querying Hierarchies: Top-of-the-Line Support
Particularly interesting facts include the ability to ORDER SIBLING BY to order within a Hierarchical query, and using SYS_CONNECT_BY_PATH to display an output of the tree in delimiter separated list.
Good reading!
I found these two really nice articles on Business Objects on Java Boutique yesterday, and thought I would share them, considering my previous post on using OO with ColdFusion.
- The Mysteries of Business Object - Part 1
- The Mysteries of Business Object - Part 2
Business Objects tend to find their way into almost every type of application development that utilises an OO approach, so understanding the concept (and you may already be doing it without knowing it) is a pretty good idea.
The second article goes through a example application, and goes through alot of the considerations to be made when utilising business objects in an application.
Obviously the articles are Java related, but due to the general nature of Business Objects, as well as the myriad of frameworks that support BO's under Java, it tends to stick to pretty vendor non-specific details, so is a good read for ColdFusion developers as well.