Thursday, April 23, 2009

Returning SQL and other query metadata

I wanted to return the sql from a query that I was running to find out why no records were returned. Found information here about query metadata that not only returns the sql run at the server, but tells you about returning the parameters too.

qryTest.getMetaData().getExtendedMetaData().sql

qryTest.getMetaData().getExtendedMetaData().sqlparameters

Monday, April 20, 2009

_f is undefined

I was getting the above error in my firebug output. It was coming from an included template that I use elsewhere on the website and I couldn't figure it out. Turns out that the page from where the cfwindow is called had a form without a name and id on it. Once I gave the cfform a name and id the problem went away and it works now.

Monday, April 13, 2009

javascript function not found and cutting corners on code

I got hungup for several hours this afternoon on a couple of stupid issues. The first, I was getting a memory leak error and my browser was freezing up so that sometimes I had to restart. Turns out I did something I do alot in coldfusion, I included the end tag of a javascript tag in the emain tag like this:




I don't know why this is but I am sure there is an easy explanation that should make sense to me, but It didn't.

The other thing that took alot longer to figure out was a cfwindow that wasn't findinng the above attached .js file. I played around with the path and all sorts of stuff and couldn't figure out why it wasn't working. Because that script tag above has to be on the parent page that calls the cfwindow, not on the page that comes up inside the cfwindow.

Thursday, April 09, 2009

ModelGlue, Flash movie not loaded.

I am moving a site over to a MG3 site. I moved a flash movie that we have and it wasn't working. When I clicked on the movie (which I couldn't even tell where it was) I got the message "movie not loaded".

After searching the ModelGlue archives there were a few messages and they did give the answer even though it wasn't directly obvious, to me, at least. I was able to navigate directly to the html page that loaded the file, but via modelglue it didn't work.

Had to use absolute paths for all path statements, including where the file only was listed. All necessary files are in the same directory as the .swf movie, but I had to add the path to each of those, and I wasn't able to use a variable set at the top of the page either.

Example: views/page/map/myfile.swf where before it worked with just myfile.swf.

Friday, April 03, 2009

SQL Server Date Formats

As part of my last post I needed to spit out the date in the right format because I was using a javascript output that I couldn't use coldfusion to format. So I needed to use coldfusion and found a great reference for formatting dates natively in SqlServer:

http://www.sql-server-helper.com/tips/date-formats.aspx
SQL query join that returns only a max value in the joined table.

I have a somewhat complicated query. This query includes 4 or 5 tables. In my app, changes to the company table are logged to a company history table. I simply record the time of the update and that it was an update. When the record is created an entry is made recording the date and the type of "create.

Anyway, some records have been updated several times and I am returning search results. The user asked to have those results returned with the last updated date, which means I needed to join to that history table and return only the max(date) from records linked to the corresponding company.

The answer was to use a derived query and I found a great example here: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=102255

Monday, March 23, 2009

CFDIV CFFORM and Asynchronous submitting

When you submit a form inside a cfdiv it submits without refreshing the whole page, only the cfdiv. This was working great unless I hit submit a second time while but you can use ColdFusion.navigate to fix this.

onclick="ColdFusion.navigate('#event.linkto('admin.countyupdate')#','countydiv','mycallBack','myerrorHandler','POST','countyform')"

Putting this in the onclick event of the cfform button fixed the issue. I had a hard time for a while because I didn't need the mycallback and myerrorhandler arguments, but putting empty quotes worked. I know, I should probably define them.

Friday, March 20, 2009

coldfusion is not defined

I finally got my development environment setup and navigated to my local site and I got "ColdFusion is not defined" error. This had to do with being able to find the CFIDE directory for the coldfusion scripts. I had a cfmapping, but that,k I guess is not enough, I had to create a virtual directory pointing to the CFIDE directory in my IIS settings.

Got the idea from this blog entry:

http://www.mattwoodward.com/blog/index.cfm?event=showEntry&entryId=607BAA40-E199-27C4-02F5BE29E69C4318
ColdFusion 8 And SQL Server 2005

I had a problem setting up a datasource for coldfusion using cf8 and sql server 2005. I read several articles:

ColdFusion And SQL Server 2005
ColdFusion + SQL Server Express 2005

It wasn't working until I went to services and started the "SQL Server Browser" service which had been disabled. Don't know why. But once I started that it worked.

Not sure which of the fixes from the article helped also, but there you go.
Installing coldfusion 8 on vista using IIS

I am trying to install coldfusion 8 on my new dell laptop and it isn't working at all. It installs with no errors, but doesn't work. I can't choose a web server and even using the web server configuration tool says there is no webserver found. But the webserver does work. The fix?

http://dale.fraser.id.au/2008/05/coldfusion-8-vista-sp1-solution.html

I think the part that really fixed it was the comment about modifying the hosts file:

Fix: The c:\windows\system32\drivers\etc\hosts file has a bizarre entry:

::1 localhost

Comment it out using notepad run as administrator like so.

#::1 localhost
127.0.0.1 localhost

I added the 127 part on my own, but this did work. Might have been the combination of changing the iis options and modifying the hosts file, but it worked. I am up and running now.

Thursday, March 12, 2009

DTSWizard.exe and Business Intelligence Development Studio

I have always hated the fact that it was so difficult to do a simple import into sql server with the new version 2005 stuff, like the management express studio. A year or so ago I spent time looking all over for dtswizard.exe and since I just got a new computer from dell I was doing the same thing. It started because I simply wanted to move some data over from excell to a 2005 sql server database.

This use to be a piece of cake in SQL 2000. You just right click on the database and choose import. No idea why microsoft would turn this into such a nightmare.

After spending the last 2 1/2 hours on this I finally find out, I think, that Business Intelligence Development Studio is where this functionality lies. Couldn't figure out how to find that. Normal install doesn't always do it. Found this forum here: http://social.msdn.microsoft.com/Forums/en-US/tfsreporting/thread/eac00857-a7af-4075-aa31-e52335c59304/

The post by a.netAvoider is what worked for me:

Thanks guys,I got away with only uninstalling Workstation components. This way you won't lose your database settings and save yourself a whole lot of installation time.To do this I opened Add/Remove programs from Control Panel, selected SQL Server 2005 Express, clicked on uninstall, and in the uninstall dialogue box which appears next unticked SQL Server 2005 instance and selected Work Station components in the list below.The I installed BIZ DEV using SQL Express Toolkit installation file. I just downloaded it now ( 17/12/2007 ). You'd hope microsoft would have fixed this issue in 5 months.

Sunday, February 08, 2009

Model-Glue 3 (Gesture)

I can't believe I am so late to the party on this, but Model-Glue 3 has been out in Alpha for 8 or 9 months now and it has some really cool features. Features that are simply amazing and will surely save lots of people lots of time. Over the weekend I stumbled across a you tube video demo (Scroll down the page to theMG3 Feature Sneak: Event Generation Video) by Joe Rinehart. Really, the thing that I wanted to try out so bad was the auto-generated code. You have to be in development mode, but you type an event into the url and if it doesn't exist MG3 creates all the best practice code that you need to make that event work. It makes an entry in the modelglue.xml, controller and view files. It even creates the controller if it needs it. Very Cool. I also so a quick touch on SES url's in that video which was interesting. This is something I have needed for quite some time.

Ray Camden has a great blog post on these many features, I think he wrote it while siting in a presentation about this, so it isn't exhaustive but it gives you a great launching pad to find out more. His blog post is here http://www.coldfusionjedi.com/index.cfm/2008/5/2/ModelGlue-3--The-New-Frakin-Awesomeness.

One of the responses on that page shows exactly how to get SES url's working:






Forbidden You don't have permission to access / on this server

I have been using this mac more and more. In fact, I hooked up to the monitor,keyboard and mouse, that were attached to the docking station for my dell laptop (Which isn't working right now) and used the mac all day on friday. No problems other than the keyboard quirks that still drive me nuts.

Anyway, over the weekend I saw a demo by Joe Rinehart on the new Moldel-Glue 3 (gesture) that has been out for some time in alpha release. I really wanted try a couple of the features, so I continued something I had briefly tried a while ago, and that is setting up virtual hosts on my mac to point different urls to different directories on the computer. I found alot of information on that and made what I thought were the correct changes as indicated in the various articles. (this is a whole other blog post). But whenever I tried to pull the new site up in a browser I got the error: Forbidden You don't have permission to access / on this server. I probably spent 4 or 5 hours changed in my settings and stuff, until finally I just moved my files to /Websites/myweb. The problem all along had to do with accessing directories in the /users directories, which is where the files I originally wanted to access were located. There were some articles on making this work, but I didn't mind just moving them to a lower directory that would be easier to find anyway.

Thursday, January 22, 2009

Blackberry Storm Upgrade

I recently upgraded from a blackberry 8703e to the new storm, I did this around December 10, 2008. First, transferring contacts and calendar was awesome, easy, fantastic. I use google synch to synch my contacts and calendar with my google apps calendar and contacts, so All I did was install google synch on the new STORM, entered my credentials and it did take a try or two (there was alot to synch) all my stuff was there.

I was severely disappointed with the battery life of the storm. But after a few days, the battery life was fine. I attribute that to overusage cause it was new and maybe battery conditioning. At first it was only lasting about 12 hours, and since I unplug it between 5 and 5:30 AM, that means it was shutting off on my way home from work around 5 or 6 pm. It now consistently lasts until midnight which is when I usually plug it in. Sometimes I plug it in for the night earlier and once in a while later, but there is still juice left when I do.

I think it uses alot more juice when you actually use it, but when it is just in your pocket or the holster, it sleeps pretty good, if you are in a digital area.

I like this phone, I don't love it. It is slow and I often have to wait for it. My brother-in-law got one and traded it in for the curve, and to tell you the truth if I had that option now I would go with the curve. The new affect was fun and it is a pretty cool phone, but it lacks in functionality because of the slowness and usability of the interface. It has froze several times, even during a phone call twice.
Adding All Option CFSELECT

I am creating a web page that makes use of related cfselect's. This is a handy feature of coldfusion that allows the contents of one select box to be dependent on the contents of another. For me that means I have one select that lists areas that our company covers. Another box lists the counties we cover. Using the related selects the counties will only show for the area selected in the first box. Very nice. I also link a jurisdiction select to the counties select.

I wanted to add a default "All" option to these selects. Colfusion has an atribute for CFSELECT - queryposition which you can set to above or below. This works great if you are not using the bind attribute in CFSELECT. I was using bind to connect those cfselects so I had to find another way to add "All". I found a comment on Ben Forta's Blog by Matt Bennett that gave me sample code like the following which I adapted slightly for my own use:



sortArray = ArrayNew(1);
QueryAddColumn(qry, "sort_order", sortArray);
QueryAddRow(qry);
querySetCell(qry, "name", "All");
querySetCell(qry, "id", "0");
QuerySetCell(qry, "sort_order", "1");


SELECT *
FROM qry
ORDER BY sort_order desc, name asc



Works great, I just added that code after the qry I was already returning and boom, success.

Monday, December 01, 2008

Export to CSV with Coldfusion

I am trying to finally get a good export to CSV working, using coldfusion. There are alot of posts, many of them by Ben Nadel.

Ended up using the example from: Converting A ColdFusion Query To CSV Using QueryToCSV()

This worked great except there were lots of blank rows at the top of the file and at the bottom. The fix was found here: Extra white-space after page proccess

<cfcontent reset="yes"><cfoutput>#Trim (yourvar)#</cfoutput><cfabort>

It was important to put it on one line to, otherwise there was an extra line for each line return.

Thursday, November 27, 2008

CF 8 - "ColdFusion is not defined" JavaScript Error

I am trying to get ajax select dropdowns to work in coldfusion 8. I eventually want them to be related also. That is, the results of the second are based on the choice in the first. Well hit a wall and couldn't get the data to show up. using a test page I was able to return the correct results with a cfinvoke of the .cfc, but no data in the selects.

I didn't have firebug installed on this computer, so I went and got it and looking at the javascript error's I saw the error: CF 8 - "ColdFusion is not defined" JavaScript Error. Google that and I found the following that explained the cause:

CF 8 - "ColdFusion is not defined" JavaScript Error

The solution was to not only have a cf mapping to the cfide directory (which I already had) but also a web server virtual directory (which I didn't have). I added the virtual directory and it works.

Wednesday, November 26, 2008

How to restart Apache on the Mac

Made a change in the httpd.conf file and wanted to restart the Apache server to pick up the changes. How did I do that?

Open up the terminal window (/applications/utilities/terminal)
Then Type: sudo apachectl restart

Seems to have worked for me.
Location of httpd.conf for Apache on the mac

It is hard for me to find things on this mac still. Some of the stuff is hidden and it always takes me a while to get around. The last thing I was looking for was the httpd.conf file for the apache web server configuration. I wanted to see where the webroot was. Then maybe change it.

Anyway, it was at /private/etc/apache2/httpd.conf.

Amazing how many posts I saw asking this same questions.

Monday, November 24, 2008

Start and Stop ColdFusion and othe services.

One of those little nuggets that I picked up at the adobe conference was leaving services you don't always use stopped until you need them. Like coldfusion for instance. I will get developing and use coldfusion locally for development for days at a time. But, I don't always use it, so there is no need for it to be running if I am not using it.

Quick search and I found this: Batch files for Starting and Stopping ColdFusion.

In Vista I had to use "Run as Administrator" for those to work, but they did work like a charm. Took a long time on the main CF service the first time, but it did eventually work.