Just wanted to point out something interesting in my investigation:
I've been pretty busy with other things, but decided to try throwing the Sun reference implementation in with custom MyFaces components.
Well, I booted up my app -- things started to look promising, then I hit a page and got an error with:
"The following JSF tags are required to contain IDs:"h:outputText""
On further investigation, I found this on the web:
http://forum.java.sun.com/thread.jspa? forumID=427&messageID=2126299&threadID=446525
I'm a long way from being able to convert all my JSF components to having IDs, but it's a start. Rob, if you have a smaller app, you might want to give this a try.
-- Jon
On Apr 23, 2005, at 7:24 AM, Rob Decker wrote:
That's my point. The problems don't occur until you reach a size and level
of complexity that you would probably find in alot of real world apps. A
simple example isn't going to cause them.
Test case 1:
Just take a fairly complex html or jsp page, throw a panelGrid in it somewhere, add a bunch of verbatim tags where needed (now we are in a subview) and away you go.
Replace the error message with "lost track in the component tree structure".
Test case 2:
Add a fairly complex tree2 structure, add a dataTable that uses the same
backing data, render the tree, hide the tree and render the dataTable, hide
the dataTable and render the tree. Click on a node in the tree to expand it.
Replace the error message with "lost track in the component tree structure".
The fix:
The findComponent method is part of the deserialization process for the
component tree. These errors could be occuring because the serialization was
probably broken.
I don't know enough about the specification (see the findComponent javadoc
for some info) at this point to fully understand what's happening here but I
think it is necessary for anyone who is going to fix these issue to
understand the process fully (specification) and all the related code that
implements it.
Once that's accomplished you'll be going "ah hah!"...refactor/rewrite then...
Simple examples aren't going to cut it alone. Fairly complex test cases are
going to be needed to put the code through it's paces. The two above would
be a start. In the end the code needs to be able to serialize and
deserialize a component tree structure of any complexity without throwing
fatal exceptions (ok maybe you want to throw for real duplicate id's but you
could also ignore all but the first, or last, and let the user figure out
where they went).
These aren't actually all that complex examples. I'd think they'd be pretty
common usage for myfaces/jsf applications. In fact, I'm sure there is a
potential to become even more complex once myfaces gets past these issues.
----- Original Message ----- From: "Jon Travis" <[EMAIL PROTECTED]> To: "MyFaces Discussion" <[email protected]> Sent: Saturday, April 23, 2005 12:22 AM Subject: Re: duplicate ids
If you have a very simple example that shows this problem, please post it so we can work on a solution. Unfortunately my setup that breaks is fairly large.
-- Jon
On Apr 22, 2005, at 4:15 PM, Rob Decker wrote:
I've seen that exception with the verbatim tag as well. It was one of the reasons I started stripping out jsp/html code.
In my opinion, release software shouldn't be throwing out fatal exceptions like these two examples.
Specifying ID's everywhere will not help all that much. If the
component
tree gets too big and complex, things start breaking. Code like this
is not
designed to handle it and the fact that it's throwing an exception
with a
misleading message to mask an earlier blunder is just an indication of
what's underneath it.
This code needs to be fixed if myfaces is going to move forward to handle real world application development. The application I'm writing is really simple from the UI perspective. I shouldn't be having this much trouble with it. Personally I think software marketeers should tag there 1.x releases as betas just to show a little honesty and integrity.
----- Original Message ----- From: "Jon Travis" <[EMAIL PROTECTED]> To: "MyFaces Discussion" <[email protected]> Sent: Friday, April 22, 2005 6:40 PM Subject: Re: duplicate ids
Seems as though there are more problems with that method than just the one you're pointing out (may be related, though).
I have a verbatim tag that actually blows up with a ClassCastException
in the doEndTag when trying to cast to a UIOutput.
Since the component type is defined to be javax.faces.Output, you'd expect that this would always succeed.
Unfortunately, in the UIComponentTag, findComponent() does:
_componentInstance = parent.findComponent(id)
which (in my case) happens to return a panel grid.
Note, I'm not specifying any IDs in any of my tags. It appears that if you want to be safely using myfaces, you'll have to be specifying IDs everywhere.
-- Jon
On Apr 22, 2005, at 8:32 AM, Rob Decker wrote:
I'm looking over the UIComponentTag.findComponent(id) method where
this "problem with
duplicate ids" exception is thrown. This code doesn't even check to
see if the id is a
duplicate. It simply checks if more children were added to the parent
than the size of
the list of children the parent has. The component in question isn't
one of the
children because just prior to (and the reason for) executing the
code
that throws
this exception was that the id wasn't found as a child of the
component.
The issue here is that sometime earlier the code lost track of the count of siblings and this exception only masks that bug. The comments don't give a reason for adding this index check but there is a comment about it:
* Revision 1.16 2004/04/20 10:54:21 royalts * added index check to findComponent
Does anyone have any info on this?
-- Rob
@objectsource.org

