Archive for May, 2005

Uncategorized

Broken PowerBook Keyboard

Well at least I thought so.  I was sitting here working
away.  Writing code like no bodies business.  And all of a
sudden my keyboard stop responding.  After a little further
inspection I find that its not entirely stoped but the few keys that do
work dont do what they are supposed to.

This is not a good time…. I am knee deep fighting to finish someone elses project, and my powerbook wont let me type.

Now picture me just on the edge of hysteria when I notice a
trend.  the 7 8 9 keys work,  the 0 is a / though.  All
i am getting is number and arithmetic operators…. That seems
odd.  1 2 3 dont work.  but j k l output those number.

Wait a minute….those keys have those letters on them too.  What does that mean? Oh, I guess thats what NUM LOCK does!

Can you believe it.  I actaully spent 10 minutes in
pre-hyper-freak-out-mode before I noticed the stupid little light that
tells me num lock is on.

I share this story just in case someone needed a laugh after a hard
mon…tuesday back at work.  And maybe to spare someone the panic
i just enjoyed.

Uncategorized

More on Hibernate in CF

So I have hibernate working with cf now.  I am pretty happy
with the results so far.  But I have a real hang up about having
to have all the config stuff in the classes directory inside the
server.  This is a large part of why I embarked on the
classLoader.cfc.  So what I found was that i can get around that
partly by utilizing the methods of the hibernate Configuration object.

By default when hibernate loads it looks in the classpath for its xml
config and properties files.  However buy using the addResource,
addClass, addXml methods you can load up all that information with out
the config files.  So what I have done is drop my classes and
class mapping files into the lib directory for my test website. 
After I initiate my hbConfig = org.hibernate.cfg.Configuration I can
then use my classLoader.cfc to load the User class from my lib
direcotry.  Now as an object this doesnt do me alot of good. but
by calling user.getClass() I have something I can pass into
hbconfig.addClass().  When I do this hibernate looks for the
User.hbm.xml localling in the lib directory.  And then continues
execution happily.

So you might be thinking that we are set then, but that is not the
case.  When it comes time to create your session from which you
will call your queries and such, it errors.  It now tries to load
the User object, but because cf loaded my hibernate config object, it
looks for the User object on the classpath again.  And seeing as
that is what i am trying to not have to do, this throughs an error
because the file is not there.

So i am thinking that if I can find some way to load the hibernate
config object with my class loader then I could alleviate this
problem.  However I am not sure how to go about this
exactly.  Anybody have any ideas?

Uncategorized

Loading java classes from an arbitrary location

This problem began with me just wanting to use my pojo’s and not
have to worry about where they were.  With a little help from this post by spike
i was able to get around that problem.  With spikes code you can
load your classes from any aribtrary location.  Which is a cool
thing by me.  I quickly turned his code into a cfc so that I coudl
easily pass in the path and class and have it return the object for
me.  I was concerned though that when a class loaded by my class
was called it would look on the class path of cf.  This was not
the case, it loaded it fine, but I found another problem.  When I
used the example of a User object and a Phone object i found that the
phone object didnt get recognized as Phone.  On my user object I
have a setPhone( Phone myPhone) method.  So I create my phone
object, set its properties.  Create a user object and pass in the
phone object to set phone.  This would throw an error that it was
not the right type.  After talking with barney for a bit he asked
if I was using the same instance of my classLoader to load user and
phone.  I was not.  My classLoader had one function and it
created the object and ended its life for each call.  So to fix
this I created an init method which took the path to your
classes.  In addition to init I created a load method which just
took the class you wanted.  So now you create your classLoader for
a particular set of files ( you can load files in packages ie.
net.simb.User ) and call load on it for all the objects you need.

==========================

Update:  Here is the download for the classLoader.cfc I created. 

Uncategorized

Window Switching in OS X

While barney
and I were hanging out this weekend, he raised a problem in osx that I
had not really ever noticed.  Because most of the applications I
use are all contained within one window.  Firefox has tabs,
Eclipse has tabs, Mail only has one window.  The problem comes
when you use the keyboard shortcut (cmd+tab) to switch applications,
that is all you get - just applications.  So if you have
Dreamweaver open with a few docs, or multiple browsers, you can not
pick "which" of these windows you actually want.

So being the good friend that I am, I went looking because this
bothered him ( and because I was bored, probably more about me being
bored).  What I found was a recent post over at Eric’s site.  He posted (only 1 day earlier) about a program called "which".  Which is an application switching utility that allows you to switch between actual windows, not just applications.

It appears to be a very useful solution so I wanted to share.  I
remembered finding this today, while reading this post over at Sean’s site
One of the comments was talking about application switching using
spotlight (which I dont get but I will leave it alone :P ).  So if
you ever run into this problem, take a look at Which.

Uncategorized

Celebrate CF’s 10th Bday in Portland

I dont have much information on the event yet but I wanted to make
sure anyone reading knows that we will be having a CF party in portland.


Macromedia’s Worldwide Party
starts at 6pm(est) on July 13.  This
event will likely take the place of our cf_social event for july.

But for sure, the CF party will be represented in Portland!

Uncategorized

Firefox Art at Oregon State

I love Firefox.  I think its a great browser and I plug it
anywhere I can.  But a group of students from OSU did a little
project to raise awareness (and I am sure waste some time).  I
think you will like it.

I am willing to bet this may be the largest firefox logo yet created!

Uncategorized

Using Hibernate in CF

Hibernate
is a an object/relational persistence and query service for Java. 
With Hibernate you create your model using POJO’s (Plain Old Java
Objects) and configure an xml file per object to be persisted.  So
with the Hibernate libraries installed its very easy to instantiate a
db session, populate your POJO, and pass that into a save method in
your session.  Thats it.  No inserts, no DAO code, just a
couple calls and its done.  And I want to do this from my cf
apps.  Seeing as there is a group devoted to just such a topic, I am not breaking any new ground here.  In fact, all I have been working towards is making Matt Woodwards example
code (available to group members).  And after a bundle of work I
have finally succeeded.  Read on to see what I had to do to make
the demo application work.

The demo code that Matt released is a simple user manager
application.  In the Application.cfm we set up our application and
then instantiate our hibernateConfig object into the application
scope.  Because the hibernate configuration regards our whole
application, we dont need to worry about setting it up each request,
just once per application load.  Then for the example the next
time we use hibernate is when we enter the user edit form.  When
you load the edit page we create a session using our hibernateConfig
object in the application scope.  Then using that seesion we pass
in the criteria to retrieve our user (ID).  This will retrieve the
data from the database and actually return a user java object that is
populated with our data.  We can then use the getters on the user
object to display the data for our form field.  You can imagine
how the update and delete process goes.  If you would like to
review the code to see what I am talking about, head over and join the
cfhibernate group on yahoo groups.

So i hope by now you are thinking this sounds like something you would
like to investigate further.  I know that I was very eager to move
forward.  So I followed the only instructions that were available
to me, the hibernate tutorial instructions.  However as it turns
out CF already uses several of the java libraries that hibernate tells
you to install.  As you might imagine this causes conflicts, and
problems arise.  Also the hibernate instructions tell you you need
many more libs than are actually required for basic hibernate
functionality.

I am doing this on my mac and so the j2ee installations are the only
option.  From my discussion with Matt he was able to get this
running on the standalone install of cf7, but i dont know if that was
linux or windows.  

So I will walk you through what I did.  First thing is to set up a
new instance of cf in jrun.  You dont have to but as we are going
to be messing around in the core of CF, I figure its a good idea. 
The next step is to pick up the hibernate libraries from the
Hibernate.org site.  I pulled down the 3.0.4 set.  Unzip
these and travel into the created folder.  Inside this folder you
will see plenty of interesting things, and as yo learn more about
hibernate some of it may be of use, however at this time we just need
the hibernate3.jar file and some others inside the lib
directory.   These files (listed below) will need to be put
in the {jrun-cf-instance}/cfusion/WEB-INF/cfusion/lib folder. 
Please copy these files:
  antlr.jar
  cglib-full.jar
  asm.jar
  asm-attrs.jars
  ehcache.jar
  hibernate3.jar
  jta.jar
  dom4j.jar
Also for this demo application you will need the mysql-connector-j jar
from the mysql site.  But with those jars in place you are now
ready to begin building applications with hibernate.

The next step is to set up our actual demo application.  Once you
have retrieved the zip file from the yahoo groups site you can unzip it
into the document root for your cf instance.  In that folder you
will find a sql file, which contains the structure we will need in our
test db.  There is only one table and some dummy data in
there.  The application uses the dsn of cfhibernate, so you will
need to set up a datasource in cf admin to connect to that new database.

The next files we need to work with are the actual hibernate config
files.  In the lib directory of the cfhibernate project
(downloaded from yahoo) you will find 5 files.  The one we are
most concerned with is the hibernate.cfg.xml file.  In side here
you will see the configuration details for our db.  This file
tells Hibernate how to talk to our database.  You will need to
replace the information in the file with the same information you used
to create our cf dsn.  At the bottom of that file you will find an
include of the User.hbm.xml.  This is the xml file that maps how
our java object will get persisted to the database.  You can take
a look at that if you are interested, but it doesnt require any
changes.  These files from the lib dir need to be copied to the
classes directory in {jrun-cf-instance}/cfusion/WEB-INF/classes/.

Once you have these files in place you can restart your cf instance and
navigate your your cfhibernate project.  If the lib are in the
right place the page will load and you should see a list of
users.  this page uses cfquery so nothing special has happened
here yet.  What you really want to do is click to edit 
user.  This is where I was running into trouble.  But if I
managed to walk you through all the steps, and not ramble too much, you
should see a form with that users information in the input boxes. 
If this is the case then you are set.  you can update and delete
the users, even add new ones.

This was a long post, and I am a bit tired, so I am very sorry if I
ramble or if i have missed anything.  I hope that in the near
future, i can make this into a real howto and get more into the actual
setup of the xml files and such.  But i was very excited to have
this working and I wanted to share.  Let me know if you run into
any troubles with my instructions and I will do my best to help you
out.  Obviously I am not an expert in Hibernate issues but I have
spent several days getting this working, and i hope you will not have
to do the same.

Uncategorized

Official CFUNITED community supporter

The t-shirt says it all.  Just got my registration pack for the
CFUNITED conference.  Boy am I excited.  Cant wait to get
back out there and hear everyone speak!  Its gonna be great!

Remember the conference is longer and has more tracks and
presenter.  The whole thing is a bigger event.  Make sure you
sign up soon to take advantage of whatever early bird prices are
available.  Remember if you are User group attendee or you have
been to CFUN in the past, you can also get a discount.  If CF is
in your career path, there is no reason not to be at this conference.

HOPE TO SEE YOU THERE!

Uncategorized

Trying to sort things out

I have been feeling kinda scattered.  I am in a position at
work that I have not been in before.  I have an existing system
that works pretty well, i have 7 sites all running well.  But I
have been given the opportunity to redisgn the system and to use the
best technology available.  What would that be?  Well they
have left it up to me to decide.

So I have spent the last week looking at Frameworks, tools, and reading
about all the things I havnt had time for in the last year.  And
now I have a new feeling.  I feel totally overwhelmed.

After doing the DAO implementation of Ray’s blog code for my site, I
realized that writing all the classes and hacks that were required to
implement the model I designed, was not a good path to take in
cf.  The blog code is a small app and the new app i would be
designing is huge.  I cant imagine trying to manage all of that
using similar practices.

This led me to look into Hibernate.  I wrote a couple demo java
apps and was supremly impressed with the simplicity of the
persistence.  create a session, create a transaction, open up your
favorite pojo, call session.save(pojo), close the transaction, close
the session.  Using xml files to map your pojo’s to your database
schema it does all the hard stuff.  So I moved on to trying to use
cf and hibernate together.  Unfortunatly it appears the log4j that
is used in cf and the log4j in the libs for hibernate dont play well
together.  So until I figure out how to get around that i am kinda
stuck.

Anyway, I guess I just wanted to post about it, to sort things out in
my head.  And it never hurts to see if others have any ideas or
suggsestions about my thoughts.  There seems to be a trend among
the CF’ers of late.  That is "quit whining about what cf cant do
OO, and utilize the strenghts that it has"  and one of those
strengths being the easy use of java.  So i am looking that head
that way.  Problem is from where i am, I cant see the path.

Uncategorized

PDX CFUG Tonight - Fusebox 4.1

Just a reminder that Barney Boisvert is presenting on Fusebox 4.1 tonight at the cfug.  Hit the PDX CFUG site for directions.  Networking (free pizza! ) starts at 5:30 and barney start spouting knowledge at 6pm!

Be there or be square! 

Next »