Ok, so Mozilla is supposed to be more standards-compliant than IE and all that good stuff. But why oh why does it have to mess up my tables when I give it empty table cells?? I don’t know if empty TD tags are mentioned in the spec at all, but either way, it’s so annoying to have to put a in every empty cell. Actually, it’s not all that annoying when you’re hand-coding a site — what’s another six characters to type, after all? It’s at work, with sites written in JSP, that I become more annoyed.
At work, I use the JSP Standard Tag Library (JSTL) in my pages. JSTL has a tag called c:out which basically just outputs a value. Now, c:out has this handy little attribute called default, which, in combination with the escapeXml attribute, can be used to output a nice . But it will only output this default if the value attribute evaluates to null. If the value is an empty string, you’ll just get an empty string, instead of the we need to appease Mozilla.
So here are the options:
- Write my own c:out tag that will output the default when the value evaluates to the empty string or null
- In my Struts action classes, check for empty string values, and replace them with null
The first option means that I would never have to remember to check for empty string values, but it would mean replacing all my current c:out tags (and there are a million of them), plus it means I would no longer be using the standard library, which isn’t necessarily bad, but I’d rather not have to do. The second option is more of a pain, but easy enough to do. I think I’ll probably just go with the second option. At least I won’t have to do the check for values that aren’t allowed to be empty.