Saturday, October 30, 2010

Cross domain XMLHttpRequest

It's not possible to use the ArcGIS Server REST API if your parameters have more than 2048 characters and you select HTTP GET. Of course, the REST API UI provides you the option to do an HTTP POST. But how do you do this programmatically?

You use a proxy!! ArcGIS Server provides you one here. More information oh how a proxy works can be found on the Yahoo Developer Network.

I named this post Cross domain XMLHttpRequest because in the context of ExtJS, the ScriptTagProxy doesn't support HTTP POST calls. Therefore, you would use HttpProxy (with a POST method) to access the proxy on the local server. Remember to pass the parameters as properties (instead of concatenating them to the URL).

Friday, October 22, 2010

ArcSDE Views use the incorrect field data type

I've been creating a lot of ArcSDE 9.3 views lately, but it came to my attention that sometimes sdetable creates a field in the view using an incorrect data type. In other words, if the base table has a Double field, the view will show the same field as a Long. What do you do when this happens? It's a nightmare, but one thing you can do is access the table SDE_column_registry and fix the data type there. Just find another field with the target data type and copy the row information.

It would be interesting to see if this happens in ArcSDE 10, which I'll be doing next!

Thursday, October 21, 2010

Concatenating, Minifying and Optimizing JavaScript

Doing this is as important as making sure your code compiles :). I've been reading several articles on how to do this, and they all present different approaches, this is what worked for me:

1) Concatenate the .js files: I use the copy command; however, it adds some extra characters that later need to be removed for YUI Compressor to work. It does the trick for now though.

2) Compress the files: YUI Compressor is the best choice. For it to work correctly I had to use the
--charset flag.

3) Set the content expiration date (using IIS). In my case I set it to expire after 20 days.

4) Finally, enable gzip compression. At first I thought I would need to gzip the files, but it turns out that II5 does this for you. Setting it up is not really straight-forward, check out the section Scenario 1 of this article for IIS 5.0 instructions.

Monday, October 11, 2010

Visual Studio 2010 Extensions

There is a great new feature on Visual Studio 2010 called Extensions (that I just discovered haha). It's pretty cool, specially since there is a gallery from where you can download extensions. My favorite one right now is JSLint. If you are also doing JavaScript development, you'll find it useful as well.

To get started on this new feature, go to Tools and then click on Extension Manager.

Friday, October 8, 2010

Maintainable JavaScript

This is a great screencast on best practices to write maintainable JavaScript code, check it out!

Thursday, October 7, 2010

YUI 3.0 Keeping test cases in different files

In this thread Nicholas Zakas explains how to keep test cases in separate files (instead of using just one file). I tried his solution and it worked... for a few minutes.

YUI 3.0 was supposed to be released one year ago, yet their documentation is not as good as it used to be (like in YUI 2.0). This is one of the reasons I prefer YUI 2.0. It's not as painful as learning Dojo, but it has (what I consider) major changes that are not explained in their documentation. How do they expect us to use their tools?


Friday, October 1, 2010

ExtJS combo doesn't allow empty text

The combo that I was using didn't allow an empty selection after picking a value from the list. Pretty strange, because another combo in the same page was working correctly. It turns out that the data store items need to have an ID greater than 1 because it seems emptyText uses ID=0.

So next time you use emptyText, make sure none of the items in your data store use an ID=0.

ASP.NET MVC 2 application doesn't work on IIS 6.0

Nowadays we expect things to just work. I deployed an ASP.NET MVC 2 application on IIS 6.0 and it didn't work at first. I can't remember the exact error, but it was something about the page not being found. After googling the error -and finding a lot of confusing information-, I decided to try http://www.asp.net/. I found the solution on this tutorial.

By the way, what is it with not being able to download ASP.NET MVC 2 from http://www.asp.net/. It's just dumb, being the "official" page to learn ASP.NET MVC, it should have a link to download it.