Wednesday, July 11, 2007

Where I work we use a CMS (Content Management System) for our external site. We happen to have a very flexible system from a great design and software house in Houston, BrandExtract. This system works well because it uses XML as its base. This allows us to use XSL to create our page templates. This allows us a great deal of flexibility, however even XSL has it's limitations. Embedding Javascript in to your xsl can be a little tricky at best and down right aggravating most of the time.

We have a project to integrate a part of our site with a partner using Web Services. I figured that this would be the perfect time to use AJAX to delivers the content and throw in a couple of bells and whistles that give the application that ""Web 2.0" feel. I wrote the AJAX library we're using for the content delivery and we are using  Scriptaculous to handle the shiny  User Interface Effects.. Now let me stop right here for a minute. I'm using Scriptaculous to handle some of the DHTML effects used to provide the interface effects that people equate "Web 2.0" with.

I also want to clarify something. I believe that "AJAX" and "Web 2.0" are used interchangeably, when they really shouldn't be. One is used in the other, however are not interchangeable. You see "Web 2.0" is a group of features and technologies a site may have including: RSS, tagging, user provided content displayed in a community selected method, AJAX, and DHTML to improve the web interface. If you'd like to read more about Web 2.0, Tim O'Reilly, coined the phrase and has a great article on what he believes the platform of Web 2.0 to be. Several good examples of Web 2.0 applications are flickr and digg.

However AJAX is different, in that it is much more of the data transportation method used to refresh data on the page without having to reload the page in the users browser. AJAX stands for "Asynchronous Javascript and XML". So what AJAX basically does is to use the "XMLHTTPRequest" object in Javascript to retrieve or post data to the server, so that there is still a round trip to the server.

Alright so we have the basics. I use a javascript library, that I wrote that's pretty simple but so far has been able to handle most of the ways I've used AJAX, which is mostly retrieving data from the server from a specific URL with specific parameters. I wrote three functions in Javascript that helps make getting the data and putting it in a "<div>" tag, and I'm done. So let's take a look at the code and go over the functions.

function getXmlData(newUrl, div)
{
xmlHttp= GetXmlHttpObject();
myDiv = div;
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request");
return
}
var url=newUrl;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
    loadDataToDiv(xmlHttp.responseText, myDiv);
    }
}

function loadDataToDiv(text, div)
{
document.getElementById(div).innerHTML = text;
}

function GetXmlHttpObject()
{
var objXMLHttp = null
    if (window.XMLHttpRequest)
    {
    objXMLHttp = new XMLHttpRequest()
    }
    else if (window.ActiveXObject)
    {
    objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
    }
return objXMLHttp
}

So the first function we'll go over is the GetXmlHttpObject(), this function returns a XmlHttpRequest object, bascially it just figures out which version of the XmlHTTPRequest object to use depending on your  browser, and returns it for use in other functions. The next function is loadDataToDiv(text, div), this function is actually a method that takes the parameters text, and div, and simply puts what text is passed to it and sticks it in the div that you asked it too. The next Function is stateChange(), which is very XMLHTTPRequest object specific function, which checks the state of the request and if the state is ready (xmlHttp.readyState ==4 || xmlHttp.readyState == "complete") then it calls the loadDataToDiv function and passes the xmlHttp.responseText, and the div you've called.  The final function, which is the one that you actually call in your code is getXMLData(newUrl, div), this is the function the brings it all together, you give it the url of the content you want you AJAX app to display and the div tag id that you want to refresh the content in.

Alright so far, we have the Javascript/AJAX part taken care of, now we need to talk about the XSL part of the equation. We will talk about that in part two.

7/11/2007 8:42:52 AM (Pacific Daylight Time, UTC-07:00)  #    Comments [1]
 Thursday, June 28, 2007
At work we have a system that I feel works pretty well, it does have some hiccups from time to time but overall the pros outweight the cons. You see we have our development machines as virtual machines. We have a beefy server that we've installed Microsoft Virtual Server 2005. On that server we have our development virtual machines setup. This setup works very well for two reasons. One, you always have access to your code on your development machine as long as you have internet access. I've tried syncing a laptop to a desktop and it never worked that well for me. Second it's a server on the network, therefore it is in the backup schedule. It's easy to think to yourself, I know I should back this machine up tonight, but I'll do it tomorrow. But having things done this way, you actual have a backup.

However once in a while you find little issues that crop up because of it. Issues that won't happen on a regular machine. This morning I was using Visual Studio 2005, and decided that I would trying doing this the new way, and create a database in SQL 2005 Express through VS2005. That's when I ran in to the error.

Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.

Well after several google searches I still couldn't figure out the issues, everything looked configured correctly. Then I found the answer, I can't say it was one I was happy with but it was the anwser. It was right there clear as day in Microsoft's Knowledge Base Site. http://support.microsoft.com/?id=896613

Cause

This problem occurs because the Local Security Authority (LSA) uses the remote session's token for the SQL Server client's session token. The remote session's token is from session 1, and the SQL Server client's session token is from session 0.

The Fix

Well that is where things get a little sticky. Microsoft doesn't have an official hotfix for this issue on their site. They do have one but you have to call Microsoft support and support has to double check that your issue is specific to trying to use SQL Server 2005 Express through Terminal Services. And then they'll give you the hotfix. Which sounds like it could introduce more issues than it fixes, so for today, I'll just use my SQL Server 2000 development server and be happy with it.

6/28/2007 1:49:29 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]

Design for Humans

Yesterday I came across this article that I thought really drove him some of the key points of consideration that web designers in their toolbelt. The article is called "Human to Human Design" by Sharon Lee. She makes a great first point by saying, we have to remember that the user on the other side of the computer is a human, our intended audience.  She basically gives a good case for using user case studies in your design. For example, you are creating a website that Loan Officers login to and check what leads they have to work with today. These are busy people who just want the information, but may want to be able to sort it by a couple of different yet common columns. Knowing that about your customer, you aren't going to want to have a large flash based splash page that takese 30 seconds to load and 60 seconds of play time. That's not what they want or need. They want to get in, get their data and get out. So thinking about them while designing, you end up designing a page that is lightweight and quick, gives them their data, the way the want it.  Anyhow, I think it's a great article and definitely worth the read.

 

Time for Accuracy

    As a Developer you always want your application to be fast, useful and well liked. It's great when things work well. However, things don't always work well. From time to time due to hardware or application performance the application is "slow". "Slow" is a word that most Web Developers just hate. Mostly because it is so subjective. 30 seconds may be perfectly acceptable to one user, while another will complain that it's too slow and that they just cant work like that. The subjectivity of time makes it really hard to see what the real problem is. This is where having something in place that takes the subjectivity out of the equation and add objectivity back. So I wrote a down and dirty little app that proxies a URL and times how long it takes the network to get that page, and then javascript is inserted on the page so I can measure how long it took the page to load on the users end too.  Fun Stuff.

6/28/2007 12:39:12 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]
 Wednesday, May 23, 2007

Well I haven't written an actual post in a while. I don't claim that this one will be an actual post either, but it will be closer to one them my last three or four attempts. Well between work, family and my hobby (obsession, yes you are right my Beautiful Wife) I've been keeping myself pretty busy. I haven't felt much writing. A blog or, well any other form of writing, journals, short stories, novels, three volume novel etc, are all ways of expressing ones self. Lately I've been doing that with my photography. So I haven't really felt the need to write. However dear friend I've recently experienced something that photographs cannot capture. Mostly because it's auditory.  So on to the back story, from the time I was about 14 years old till I was 24 or so I worked construction with my Dad. It was some of the hardest work and most fun I've ever had. I don't know if you've ever been on a construction job site, but in the 80s and early 90s when I was, there was always one radio on the jobsite with the volume knob turned to 11, blasting rock. Big Hair rock to be exact. Skid Row, Poison, Slaughter, Firehouse, White Lion and many many more. So as with most people, these songs bring back memories of the good times.

Some more back story, As many of you know my Grandma K passed away in November, in a very wise decision, my Mom and Dad and Grandpa K are remodeling Grandpa Ks house, so they can all live together. Being that both of my Brothers are in construction, my Dad is a Sr. Building Inspector for the city, and I have ten years in construction, we felt and knew that we could handle most of the work ourselves. It cuts down on costs and we know it is done right. So the first phase of the remodel/addition is to remodel the kitchen. It was just too small for the number of people cooking in it at one time Sis/Mom/Dad/Brother J, sometimes Brother K and occasionally me. So some walls were moved, some were removed and viola the kitchen is bigger, now we need cabinets for the new walls. We are effectively tripling the amount of cabinet and counter space in the kitchen. Which means there are a lot of cabinets to make. Well cabinetry was and still is one of my favorite facets of construction. So this was the part I was asked to help with.

Sunday was my first day helping build cabinets. We worked till 7pm that night, I was so stiff and sore. I had used construction muscles I haven't used in a decade. However it was a lot of fun. All the tools have been updated. The nailguns are lighter, the miter saw has  a laser sight on it, so you know where your cut will be. And the cordless drills are stronger lighter, and even have a light on them that shines when you are driving in a screw. So while these toys... I mean tools were very enjoyable to work with. Working with my Dad and Brothers was even better. It was like old times, but just a little bit better, because we are all a bit older and maybe even a little bit wiser. As the tools were updated, so was the radio, the Boys were cranking 80s music, however it was from a channel called "Hair Nation" on Sirius Satellite Radio. Man did this take me back.

Well last night I went over to help, we still have a ton more cabinets to build. And of course, we were listening to 80s rock. So I guess that until this project is done, I'll be a cabinet member of hair nation.

Family | Funny | General | Rant
5/23/2007 8:40:14 AM (Pacific Daylight Time, UTC-07:00)  #    Comments [1]
 Wednesday, May 02, 2007

My Beautiful Wife sent this to me, and I have to say I just love this. I've watched it 5 or 6 times in a row.

5/2/2007 10:26:38 AM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]
 Tuesday, April 17, 2007

I have no idea if this is a joke or not, by Adobe just released a site through their  Adobe Labs on  April 15 called http://adobenostalgia.com.It looks like it tries to "process" digital images as you would process film. It picks a tank size for the images you are important and even asks you which chemistry you'd like to use to develop them. Then you Using a enlarger you can make test prints, contact sheets and prints of your images. Like I said, I don't know if it's a Joke or not, but it has my interest.

4/17/2007 1:47:01 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [1]
 Wednesday, April 11, 2007

 Warning: This is a tech post. So if this stuff bores you to tears, you may just want to skip it.

Sometimes you think you know how things work, or how a language works and you get a project that just makes you rethink how you use a certain technology or programming language. Well I've been finding that with Javascript lately. Especially digging in to AJAX/XMLHttpRequests objects. The IDE(Integrated Development Environment) I use for coding up html and javascript pages is HTMLKit. It's a great IDE and is shareware, which is fantastic and it allows you to write your own plugins for it. However, in browse mode it does use Internet Explorer (IE). Well IE is a great browser for lazy coders, it finishes your tables, and lets a lot of Javascript do a lot of things, that other browsers just don't do.

 

Firefox however likes to make you work for it just a little bit more. So what I found is while I was making a call to a page on an outside domain, I was getting a very strange and serious error. "uncaught exception: Permission denied to call methods XMLHttpRequest.open." Well this was confusing, how come it works perfectly in IE, but Firefox is giving me this error. Well after a quick google search on the error I found my answer. Simply put Firefox, or More correctly any Browser from Mozilla has a "security" feature that doesn't allow a XMLHttpRequest.open call to a url that isn't on the domain you are using. Funny enough, I've written several AJAX applications, but all of them only call within their own domain. So this error was completely new to me. One of the links that I helped pointed out that you have to set a specific property.

 

   try {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
   } catch (e) {
    alert("Permission UniversalBrowserRead denied.");
   }
4/11/2007 8:31:53 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]