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.