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.
I am also facing the same prolem. I clubbed both lable and inputtext in , also I exchanged the places of both to make avaialable inputtext before label. But the problem is still there. I am getting this "Unable to find component with ***** ID" message in log.
Posted by: Dhananjay at November 2, 2004 11:27 PMHey Dhananjay, thanks for your comments. You could try putting them inside h:panelGrid and/or make sure that you are running the latest JSF RI release from Sun. There's been a few minor releases with bugfixes already. Or, you could try out MyFaces (www.myfaces.org), which is an open source implementation of JSF. I've been very happy with it, both because of the additional components in it and because it fixes some bugs in Sun's RI.
Posted by: Alphageek at November 3, 2004 10:20 PMSame problem here. I solved it by placing components in absolute positions. This way the actual order in html dosen't matter.
Posted by: Kim Daugaard at March 16, 2005 08:56 AMHi,
I solved my problem put a and all my html tags into a tag.
First #:
...
:( sometimes I think in just put outputLabel AFTER inputText :P