Archive for July, 2008

SSL on Apache 2.2 with Windows

Monday, July 14th, 2008

I’m collecting information on generating a SSL cert using an internal CA cert using OpenSSL with Apache 2.2 on Windows. I found most of the OpenSSL info on this page. This will be work in progress until I am done.

You’ll need:

  • Apache 2.2 install with OpenSSL. I used the Windows installer, which includes the openssl binary. It looks like installing the Cygwin OpenSSL package will also install this binary, but I don’t know if it is compatible with the version of OpenSSL that ships with Apache.
  • CA cert for your organization (.cer).
  • Private key file for CA cert (.key).
  1. Open a command prompt and set the OPENSSL_CONF variable to point to the local Apache OpenSSL config file: set OPENSSL_CONF=c:\Program Files\Apache Software Foundation\Apache 2.2\conf\openssl.cnf. Note: do NOT use double quotes.
  2. Generate the private key for your server: openssl genrsa -des3 -out server.key 4096
  3. Create and sign certificate request: openssl req -new -key server.key -out server.csr

SQL Server: Compound update/select

Thursday, July 3rd, 2008

I am learning SQL. Slowly. I mean, beyond CRUDdy stuff to more advanced queries.

I wanted to reserve the first unused element in an object pool that I’m storing in SQL Server. Turns out you can do that in one compound query:


update poolTable set consumerId='someid' where poolObjectId=(select top 1 poolObjectId from poolTable where poolObjectId is null);

Training wheels? Still on. But learning.

Handling Drop Down Events in a YUI DataTable

Wednesday, July 2nd, 2008

Ok, I am blatantly copy/pasting stuff from the manual now, but again I like how little work I have to do to handle events from the data table:

   myTable.subscribe("dropdownChangeEvent", function(oArgs) {
      var elDropdown = oArgs.target;
      var oRecord = userTable.getRecord(elDropdown);
      doSomething(oRecord.getData("fieldname"),
		      elDropdown.selectedIndex);
   });

And since doSomething just reuses my function to send an AJAX request, everything gets updated for me.

Now, one question I have is since I’m using a somewhat hacky method of using Prototype to send requests, would it be cleaner to use YUI? Am I missing some caching that could be happening?

YUI DataTable Static Cell Content

Wednesday, July 2nd, 2008

So, I want to have a “Delete” link for each row. This is where the DataTable cell formatters come in handy.

Write a formatter that will call a JavaScript function. You have access to all your data for that row, so it is easy to pass that data along.


var deleteFormatter = function(elCell, oRecord, oColumn, sData)
{
elCell.innerHTML = "Delete“;
}

Then, in your column definition for the data table, just use that formatter.


{key:"del", formatter:deleteFormatter, label:"Delete"}

I am using a weird mix of YUI and Prototype, as I haven’t invested the time in figuring out YUI’s request model yet. But what I realized is I can reuse my response handler that I wrote for adding data to update the table after deleting rows as well. Sweet.

Refresh a YUI DataTable

Wednesday, July 2nd, 2008

How to get my DataTable to refresh?

userTable.getDataSource().sendRequest(
'',
{ success: userTable.onDataReturnInitializeTable,
scope: userTable });

This will tell the data source to send a request to the remote server, then redraw the table.

I got it off the internets at this site. Looks like there is more good stuff there for us YUI n00bs.

Yahoo! UI DataTable and DataSource Errors

Tuesday, July 1st, 2008

A couple notes as I learn how to use this framework (note that I am using 2.5.1, the latest version is 2.5.2 so I need to upgrade today):

  • If you see “Data Error.” in your table, make sure you have included all the necessary dependencies.
  • If you see “Loading Data…” and you get a JavaScript error along the lines of “oRequest is null or not an object,” make sure the URL you constructed your DataSource with contains a “?”, even if it’s unnecessary and is the last character in the URL.