For the past few months I've been experimenting with JavaServer Faces. 1.0 specification and a reference implementation was released just a month ago by Sun. I'm quite familiar with Struts, so it wasn't too hard to get started with JSF. However, it's just different enough to require a lot of learning (and un-learning of Struts). While I initially thought I would just use JSF with Struts, I've realized later on that the only thing I really need in addition to it, is Tiles. After experimenting with it a bit, I'm relieved to notice that Tiles and JSF agreed to play nicely with each other. JSF validation, navigational model and direct binding to Backing Beans bring enough of the functionality Struts offers that I don't really miss anything from it. Some might think otherwise, I know.
Anyhow, while I was hacking along, I run into my first official JSF bug. That's what you get when you work on the latest technology, I guess. In any case, I'm quite annoyed and disappointed about it. I tried to use the tag outputLabel:
< h:outputLabel for='id' styleClass='field' >
< h:outputText value='#{bundle.text_id} '/ >
< /h:outputLabel >
< h:inputText id='id' size='16' value=''/ >
Testing it, I got a warning: "Unable to find component with ID 'username' in view", while I clearly had the ID there. After just a bit of googling, I found the reason from this thread in Sun's Java forums. Apparently, the component specified by the attribute "for" is only found if (quoting the forum thread):
(1) The "for" points at a tag that comes before
(2) The < h:outputLabel > and the tag that it labels are both inside a "rendersChildren" tag - like < h:panelGrid >.
(3) The page is being re-rendered in response to a postback (for example, when validation fails)
Come on now Sun, did anybody there ever test this stuff? It's a bit frightening that this is such an obvious bug, and it still managed to slip by the quality control. Well, maybe outputLabel was added late in the process, but still. And god damn it, why doesn't the outputLabel support the value attribute (even though it's documented in the Javadoc). Did anybody ever think about how to use this stuff either?
Despite the ranting part, I really like JSF, so my sincere thanks to Sun. This is the way web apps should be made - as long as we are (and we probably will be for the foreseeable future) still stuck with this sad, primitive http-based browser environment streched way too far for complex rich-media web applications.