Friday, May 9, 2008

Where the Bleep is Java 1.6 on OS X 10.5 Leopard?

Well boys and girls, I have been too busy with work to notice that Apple has finally released Java 1.6 for OS X. But only for 64 bit processers, if you don't have one of those in your system, you are out of luck.

But if you do, just run System Update and you should get the update. But after installation, when you drop to command line and run:

java -version

It still says version 1.5. Where the bleep is Java 1.6? You may ask. Well it located here:
/System/Library/Frameworks/JavaVM.Framework/Versions/1.6/commands

Just make symbolic links to the executables you wish to use.

Tuesday, May 6, 2008

Ajax Pioneer Week at Ajaxian

Ajaxian is having a pioneer week on their site where they are showing some interviews with Ajax heavyweights. I'll update the links as they post their links:

Monday, May 5, 2008

Sending Test Params with Dojo

I wanted to send some test data to a server script from Dojo but I didn't want to create a form. After a little snooping around I found out the content property the xhr object will do this. However, I didn't find a lot of examples of how I was supposed to format the field.

The documentation seems to indicate param=value, but that obviously wouldn't work. Below is an example of what works. Basic object literal format seems to do the trick. Just separate your name name:value pairs by commas and you should be good to go.

   1:      dojo.xhrPost(
2: {
3: url: 'ajax-student-test.php',
4: handleAs: "text",
5: timeout: 5000, // Time in milliseconds
6: content: { AppRequestType:"Initial Page Load" }, // Data to pass
7:
8: load: studentHandler, //Called on a successful response.
9: error: ajaxErrorHandler, // Called in an error case.
10: }
11: );
12:

Friday, May 2, 2008

Comment Filtered JSON with Dojo

As you may or may not know, I'm working on a project at work using the Dojo JavaScript Framework. I have been working on the JSON examples. When I tried to use the standard xhr JSON handler for my JSON text, I got a message stating I should use Comment Filtered JSON instead.

So what the h*#l is comment filtered json? After must searching around and a little testing I finally figured it out. To prevent some other poor bastard from doing the same search, here is an example.

   1:{
2: "name":"South",
3: "type":"COED",
4: "size":200,
5: "students":["John Smith", "George Washington"]
6:}
7:
8:/*
9:{
10: "name":"South",
11: "type":"COED",
12: "size":200,
13: "students":["John Smith", "George Washington"]
14:}
15:*/


Lines 1 to 6 are regular JSON text. Lines 8 to 15 are comment filtered. To make JSON text comment filtered, simply put the text in a comment. That's it.

NetBeans Reconfiguring My UI

Just a quick complaint about NetBeans. I keep reconfiguring my UI by accident and I find this very annoying. For example, I'll try highlight some code, and cut and paste it. By accident I'll grab the edge of something and voila! Half my UI just disappeared. There really needs to be a dialog that says "do you really want to reconfigure everything idiot?" before I do it.

At least allow me to enable a setting to confirm UI reconfiguration before it happens. Just a thought.

Tuesday, April 29, 2008

PHP5 on a Java App Server

Yep you can do it. My co-worker write it up, check it out at:
http://blogs.sun.com/tiger/entry/php_on_the_sun_java

Wednesday, April 23, 2008

Grabbing a Grid Row with Dojo 1.1

I'm working on a project in the Dojo 1.1 JavaScript framework at work. The framework is very comprehensive and powerful. It has all the widgets of a Visual Basic or Java Swing. However, at this stage of its development, let's say the documentation could be a little better.

So I'm using the Dojo Grid widget to view some tabular data. What I needed to do was allow a user to select a row from the grid and then click on a button. This pops up a dialog with the data in a form for the user to edit. Well I figured it out, but it wasn't easy. So I thought I should post this code example for any other poor souls trying to do the same thing. Here is the code.

   1:<div id="grid" dojoType="dojox.Grid" model="model" structure="structure"
2: autoWidth="true"></div>
3:<button dojoType="dijit.form.Button" id="updateButton">Update
4:
5:<script type="dojo/method" event="onClick">
6: var row = dijit.byId('grid').selection.getSelected()[0];
7: var selected = dijit.byId('grid').model.data[row];
8:
9: if (selected) {
10: dijit.byId("someFormField").setValue(selected[0]);
11: }
12:</script>
13:</button>


The real heart of the issue is on line 6 and 7. First, you need to use the Dojo dijit.byId() function to grab the grid and get the selected row. This returns a integer number identifying the row in the grid. You then pass this number to the data model which returns an array containing the row data.

On lines 9 to 11, array data is assigned to the form text field. Note I check to see if selected is not empty first. If a row has not been selected, the selected array will be empty and this will cause an error if you try to assign it to the field. If there is data in the array, then line 10 assigns the first column in the row to the field identified by its ID.

I saw examples that identified the column in the grid by its name, but I could not get that to work. Using the column index numbers seems to be the only method that works for me.

I hope this will help others trying to do the same thing. Good luck!