The November 2009 Blog
send me a comment

Misbehaving Dojo Dialog (Thursday, Nov 19)
[ permalink ] [ e-mail me ] [ ]

I was adding some functionality to a web form the other day and ran across some unexpected Dojo behavior. For simplicity's sake, let's say that this is the form I was working with:

Notes form and HTML, before Dojo dialog

That's the Notes form and the resulting HTML code. I decided to put one of the fields in a Dojo dialog, just to fancy it up a bit (there was actually a better reason than "fancy it up", but that's a good reason for my example here). To do this, I added a little HTML around the field like so:

Notes form and HTML, after Dojo dialog

All was good, you could click a button to display a dialog and enter information into the field, and the world kept spinning 'round. The only problem was, when the web form was actually submitted, there was no data in the field that's in the dialog. If I didn't use a Dojo dialog the field got submitted fine; if the Dojo dialog div surrounds the field, the field data was empty. Weird.

Looking at the HTML above, it all looks good. There are a few extra tags on the page, but nothing that should clear out the field data or anything. I even wrote some JavaScript to make sure that the field data was there after the dialog closed (just in case Dojo misplaced it somehow). Still looked good. Then I looked a little closer with Firebug:

Notes form and HTML, seen using Firebug

Ah ha! Look at where the form is, and look at where Dojo moved the dialog div. The div is now beneath the form. So the field isn't inside the Form block at all now. So when you submit the form, the field doesn't get submitted because it's no longer a part of the form. If that doesn't make sense, consider the fact that there can be multiple forms on a page, each one submitting only its own fields.

My answer ended up being that I added code to copy the dialog field text to a hidden field that was still inside the form, so the field data still got submitted. There are probably other ways to work around this too. Ultimately, it just showed me that it's essentially impossible to debug web forms without Firebug these days.

Oh, and the same thing will happen if you do this on an XPage too. Dojo is an equal opportunity HTML rearranger.

UPDATE: make sure to check the comments for some other good ways to work around this problem.

Sign Up For The Teamstudio Spotlight Awards (Wednesday, Nov 11)
[ permalink ] [ e-mail me ] [ ]

You have less than a month to sign up for the 2010 Teamstudio Spotlight Awards.

2010 Teamstudio Spotlight Awards

This is the third year they're doing the awards, and it's simple to enter. Here's the process:

If you'd like an example of a winning application, Theo Heselmans won last year with a very polished Domino web survey app.

Also, even if you get to the demo stage, you will NOT be asked for source code or intellectual property related to the application, so don't worry about that. Teamstudio is just looking for companies that do interesting things with Notes/Domino because those are people who can really use their tools. And if your company is "shy" about being named in a contest like this, that's okay too (notice that the second place winner in last year's press release requested anonymity).

FULL DISCLOSURE: I am one of the judges for the contest.