Tuesday, January 30, 2007

Transfer ORM

ORM stands for object relational Mapping. I am not sure I understand everything it does yet but I do know that it automatically creates CRUD DAO objects. I use to spend hours writing beans, DAO's and gateways. Well, Transfer does the beans and DAO's automatically and even some of the simple gateway queries.

Previously I had been using http://rooibos.maestropublishing.com/ to generate beans and then I would cut and past generic DAO code for the CRUD methods. CRUD stands for Create-Read-Update-Delete. The standard things you do to an "object" or row in a database.

Setup is probably the most difficult, as anything else, especially the first time you attempt it. In Transfer you have to download the open source code from: http://www.compoundtheory.com/?action=transfer.download or you can get the latest BER (Bleeding Edge Release) via SVN at http://svn.riaforge.org/transfer .

You place this code in your root directory. You will then have a "transfer" directory under web root.

you need to initialise the transfer object, which I did for my test in my application.cfc file. You can just do it on a page if you want. You can get further instructions here: http://www.compoundtheory.com/?action=displayPost&ID=112. This page also offers examples of using Transfer for the basic CRUD operations.

Once you define your datasource and your table in datasource.xml and transfer.xml. It is this easy to get a row from the database:

transfer.get("user.user", userid).

Want a query of all users:

transfert.list("user.user")

It took me about as much time to figure out how to use the basics of transfer as it would have to generate all the DAO, Bean and simple Gateway methods for 1, maybe 2 projects, but now I can save my self tons of time not having to create those anymore.

I am amazed at the creators of such "frameworks" as transfer. They are wicked smart and provide a real value to me. Thanks to Mark Mandel and any others who devote their time and smarts.

Wednesday, January 17, 2007

Invalid Color Space error in Acrobat Reader

Had a user that was getting this error when trying to read an acrobat attachment that I sent her:
 
"Invalid Color Space"
 
This prevented her from seeing some of the images I had put in the document.
 
http://www.abcteach.com/help_topic.php?id=134 mentioned that this error would be resolved by upgrading your acrobat.

Tuesday, January 09, 2007

Google Apps for Your Domain

You can host your email for free using google Apps for your domain. This is awesome. You set up an account, point your MX DNS record for your domain as per the instructions and wallah! Google handles all your email for you and your users.

I set up one of my domains to use it and it works great. It did take one of my networks 3 days to get the dns changes but when it kicked in it worked just as I hoped. Check out the benefits:

Google Apps for your Domain

The have a few other things than just email, and I am sure they will add more.

There are a couple of downsides to this. Your email is hosted outside your company. I currently don't have a way to connect to gmail using CFMAIL.

The upsides are huge though. They take care of software, bandwidth, spam filtering, administering etc.. Lots of reasons to take advantage of this.

Friday, January 05, 2007

156 Useful Run Commands.

Interesting article about run command you can issue in windows. As it states, most are available via the GUI interface of windows, but there are some nifty ones that you may find usefull.

http://www.fixmyxp.com/content/view/20/42/
I have been using subversion for a few months now and I love it. It has been my first real run at source code control. I installed subversion locally on my development machine. This was a little difficult but I haven't had a moments problem with it since I installed it. The one drawback is accessing the code repository from remote locations. And there is also the matter of backing up and updating.

Several times I have thought about finding a subversion host online, but the meager attempts I made were not succesfull. But I came across one a few days ago and took the plunge. It was a peice of cake. For testing I started a new project. I just sent support and email about importing the existing project I had. Everything is the same. Only know I don't have to worry about backups of my code and updates of the subversion software. And best of all I can access the code from my latpop at home or wherever. It is $15.00 a month. I price I feel is fair. I had I small issue I sent to tech support and the resonded very quickly

So far so good. The site:

http://www.wush.net/
A site I came across when looking for ftp hosting. Looks like the offer other stuff too and great prices and functionality.

http://www.siteground.com
Here is a great link that explains mapping network drives when a user logs in to small business server.

http://msmvps.com/blogs/kwsupport/archive/2004/11/03/17830.aspx

Tuesday, January 02, 2007

We have some fields that we want to default to a certain value in Platypus. The main one is the suppress receipts filed. A while back, platypus support sent a script to make this work. It never did. Turns out they had a slight error in the script. The sent me the corrected script last week:

insert into options (name, value, descriptio, category) values ('Default Suppress Receipt','Y','The default Suppress Receipts option for new customers.','Customer Defaults')

This worked, but not until I deleted to old incorrect value out of the options table. I also restarted platypus. One of those two things made it work.

This gave me the idea for another field also. On my own I did the following:

insert into options (name, value, descriptio, category) values ('Default Suppress Statements','I','The default Suppress Statements option for new customers.','Customer Defaults')

This now enters the correct default value for the Suppress Statements field. I am not positive how it works, but it appears that you can add a row to the options table to cause default values. Just have to use the word "Default" in front of the actual field name. Should work for any field, at least on the general tab.

Friday, December 22, 2006

I am in Las Vegas to see the Vegas Bowl. BYU vs Oregon. The first quarter was ok. Neither team scored. Both made offensive errors. BYU dropped several easy passes, and Beck had some bad passes. After that it was all BYU. Oregon just didn't play well tonight. They finally scored in the 4th quarter on a long TD pass. They really didn't do anything all night.

The highlight was at the beginning when volunteers from Nellis Air Force base rolled out a football field size American Flag. Then the during the National Anthem, 2 air force jets flew over and hit the afterburners right above us. COOL! Definately the highlight of the evening. I want to take my boys next year so they can experience this.

Wednesday, December 13, 2006

My users have been requesting a seemingly simple feature for a while now and I could not get it to work.
 
When they enter a value, they are prompted with a javascript confirm (Ok/Cancel) box if the value is over $1,000,000.  If the choose "OK", no problem.  But when they choose cancel, they wanted to be put back in that same field.  I should just be able to do the following:
 

function checkValue(){

if (document.getElementById('valuation ').value >= 1000000){

if (confirm("This value is over $1,000,000. Are you sure you meant to enter such a large value?")){

}

else {

document.getElementById('valuation').focus();

}

return false;

}

}

I was able to set focus to any field, except the one I just came from.  The only hack I was able to find was to set focus first to another field, then the field I came from and then use the follwing in my <input> statement.  

onFocus="this.select()"

Here is the javascript function I had to use:

function checkValuation(){

if (document.getElementById('valuation').value >= 1000000){

if (confirm("This value is over $1,000,000. Are you sure you meant to enter such a large value?")){

}

else {

document.getElementById('otherfield').focus();

document.getElementById('valuation').focus();

}

return false;

}

}

 
-------------------------------
David Mineer

Tuesday, December 12, 2006

I just found out that I can have the contacts on my cell phone backed up automatically. Not only that, it provides a web interface for adding, updating and deleting the contacts on my phone. I have a verizon phone and you can find out about it at:

http://www.verizonwireless.com/backupassistant

It does const $1.99 a month. But as often as I drop phones in a glass of milk, it is worth it to me.

Several of my users have been complaining that iGoldmine was not working for them. I am not sure when it quit because iGoldmine sometimes doesn't get used for weeks at a time. But I was pretty sure it was working until sometime in November maybe even towards the end of November.

Anyway, I started researching this and came to find out that I could not run the goldmine executable which is on a network share, from the machine running my iGoldmine server. The iGoldmine server is W2K 2003 server and is just a member server of my domain. The error I was getting when trying to run the goldmine executable was:

"windows cannot access the specified device, path, or file. You may not have the appropriate permissions to access the item."

I decided to try and run some other .exe files on different network drives and sure enough, same error on all of them.

Goldmine tech support is usually awesome, but this time they just pooped out on me and had me so mad I had to go get a Dr Pepper to settle down. They didn't want to help at all.

Turns out the issue was with the Internet Explorer Enhanced Security Configuration. You can get to this in Control Panel-Add/Remove Programs/Windows Components/. After that you can check or uncheck the two options: "For administrator Groups" and "For all other user groups". Both were checked, so I unchecked them and then I was able to access files over the network.

I didn't have the same problem logged in as myself. I was able to run those files, other users, however could not and hence the problem. There must have been a windows update that changed the IE config and hence caused this problem. I would have thought the Goldmine folks would have encountered this already, cause it has probably been a month or so.

Friday, November 03, 2006

I was changing around some javascript on one of my pages and came to a piece where I wanted to access a variable several times. I remembered using a "with" statement when doing some programming Visual Basic for Access. I looked up the with statement and found out that it is not recommended to use.


alert(document.title);
alert(document.body.tagName);
alert(document.location);


Here is the with Statement:


with (document) {
alert(title);
alert(body.tagname);
alert(location);
}



"It is another scope. When you use the with statement, you are forcing the interpreter to not only look up the scope tree for local variables, but you are also forcing it to test each variable against the object specified to see if it's a property" - "Professional Javascript for Web Developers, Nicholas C Zakas, p 581

Monday, October 30, 2006

I have a dynamic region and I wanted blank lines to not show. I have owners listed with companies, but sometimes there isn't an owner name, just the company name. I use the /br/ to go to the next line to get a "Mailing Label" type layout, if there was no owner then there would be a blank line.

The solution would normally be to use a /cfif len(fieldname) = 0/ Since this is a dynamic spry region, that doesn't work. I found the solution in the forums:

spry:if examples

My version of the code is:

-span spry:if="'{FIRSTNAME}' != '';"-

Friday, October 27, 2006

Trying to a seemingly simple thing before going live with the AJAX code I have been working on. I don't want pressing the enter key to submit the form when a field is in a particular field. This turned out to be harder than I thought. But here is the code that does it:

Include the following element into the head part of your document:

/script type="text/javascript"/
function noenter() {
return !(window.event && window.event.keyCode == 13); }
/script/

Add the following attribute into each input type="text" tag(s) in your form:
onkeypress="return noenter()"

The function has to go in the header on the page. It didn't work for me putting it in an included .js file.
Still struggling with the grouping thing. The interim sort-of workaround was to just flatten the whole thing out. Like this.

here is what I want

company1
contact1
contact2
company2
contact3
company3
contact4
contact6
contact7
company4

This is what I have to do for now.

company1 contact1
company1 contact2
company2 contact3
company3 contact4
company3 contact6
company3 contact7
company4

Redundancy and not what I want but it does allow me to go live with the ajax portions of the code and not break the app. We will see what the users think.
Spry and grouping. I have a spry dynamic region that returns a list of companies that my user searches for. Well, each one of these companies can have 1 or more contacts attached to them. Currently, when they search, a popup page is presented with a list of companies that match their search value. As I Output the query, I use a contact object that gets all contacts for that company. (contact.getContact(companyid)). This is easy in Cold Fusion.

In spry however, I cannot figure out how to do it. I can output the list of companies, and I can write an onclick so that when I click on their name, the associated contacts are listed, but I can't list those contacts below the name of the company, I can only create the dynamic region for the contacts outside the company dynamic div.

I am still researching this and hoping to find a workaround. I did notice that there are some posts about grouping the spry forums, but all that is said is that it will be added to the list for future upgrades. This was back in the beginning of August. Maybe there is something available now.

Thursday, October 26, 2006

This was a post I found on the labs forums site at adobe, but I can't find it for the life of me right now. Before the IE caching problem neither firefox or ie were loading the new data after I updated the database and it turned out to be an internal spry caching problem. The following comes for the posting in the forum. The key for me was the useCache:false part that you stick at the end of the Spry.Data.XMLDataSet call.

If you're going to be updating the data set by re-loading the same URL, make sure you turn caching off:



After that, you'll want to define a function callback that will be triggered *after* your server request to update the record:


function UpdateRecordCallback(req)
{
// We just finished updating a record, force myDataSet to
// reload the data from the server so our regions auto update.

myDataSet.loadData();
}


Then use the loadURL() utility function to send your request. You'll have to pass your callback function to loadURL so that it gets called when the request succeeds:

function UpdateMyRecord(recordID)
{
Spry.Utils.loadURL("GET", "closetesrecord.php?id=" + recordID, true, UpdateRecordCallback);
}

...

While I was having the problem with caching, I was also in a not so bad problem. IE was giving me errors when Firefox was not. I was getting two different errors on an href onclick event.

When you call dynamic fields in a spry dynamic region you format them like this: {FIELDNAME}. So I had an href like this:



Firefox had no problem with this. IE, however, was having a problem and I couldn't figure it out. Finally figured out that I had to have single quotes around the spry dynamic vars like this:



That was only needed inside the onclick event, not outside. Small thing and the error didn't seem to effect the functionality, but you hate for users to get the little error each time the page loads. Makes everything seem just not right.
Building an AJAX interface for my data entry app. Was stuck trying to get a dynamic region to refresh. Turns out IE has some caching issues. I found the following page that, if you read the comments gives a pretty thorough explanation of the problem that I was having.

http://ajaxian.com/archives/ajax-ie-caching-issue

Of course I am using cold fusion and the answer was to put the following line at the top of my xml page.



I spent several hours trying different things. I had just upgraded to ie 7 and thought that could have been part of the problem. It was working just great in firefox. Glad it was an easy fix, wish I would have figured it out quicker.

I am using the adobe spry framework for AJAX. It is still in prerelease but I have really enjoyed it as it is my first serious foray into AJAX.