-
Notifications
You must be signed in to change notification settings - Fork 58
Duplicate ID exception when using composite component with c:if #4244
Comments
Reported by dstrietz |
tmiyar said: My explanation of this is, having 2 components of type "mycomposite", the first composite with conditional rendering c:if, the c:if puts some kind of flag in the view like "render" that affects all components it finds of type "mycomposite" it finds afterwards, therefore, "mycomposite2" gets re-rendered. The "scope" of the "flag" is wrong. If you move the c:if to the second composite, it works fine as the first composite was evaluated before the c:if sets the "flag". |
klavikka said: See:
I'm still waiting for a fix. I tried to figure out a solution myself, but the code appeared to be a bit too complex for me to understand. Some documentation about the internals of Mojarra would have been useful, but I couldn't find anything besides the source code itself. |
rickyepoderi said: I've been looking to this issue and the problem is related to how the internal IDs are calculated in mojarra. In the example: 1.- The first time the c:if is evaluated to false and only one composite is created "test2":
2.- When you click the show link, the c:if is true and therefore two composites appear ("test1" and "test2"). The first one is:
You see the MARK_ID is exactly the same as in point 1. The IDs are assigned using the composite hierarchy (only one here) and the tag. When there are more than one a number suffix is added (see later). Here because the "test1" is the first composite being evaluated it receives the same ID "test2" received in the previous request: "-1950651219_36361211". 3.- When the JSF implementation reaches the "test2" composite the HtmlOutputComponent received the ID "-1950651219_1_36361211_1" because there is already one with the same ID and the suffix is incremented (I mean, because "test1" exists, "test2" components get a "_1" suffix). But the previous value remains and it finally finishes with a duplicated component:
You see that the HtmlOutputComponent is duplicated, one is the old component (the rendered in the previous request) and the other is the new one (calculated this request). The problem is related to how the component IDs are calculated and not marking to delete composite children. I have a little patch you can test and I'm going to put in a second comment. |
rickyepoderi said: I have prepared a little change over 2.2.14 tag that does the marking and the deletion commented before. I have just test it against the mojarra automated test on version 2.2.14 and it passes all of them (but nothing more).
Please, consider this patch or a similar solution, but clearly this is a BUG cos this issue makes absolutely incompatible composites with JSTL that changes the component tree (c:if in this example). Thanks in advance! |
klavikka said: I'll have to setup a build environment for Mojarra and try your patch ... and understand how it works. |
zhangxinyuan said: jsf-ri/src/main/java/com/sun/faces/facelets/tag/jsf/ComponentSupport.java | 24 +++++++++++++++++++----- |
This issue was imported from java.net JIRA JAVASERVERFACES-4240 |
@xinyuan-zhang @ren-zhijun-oracle Gave this a brief glance with @BalusC and it looks like the following check is missing for the new delete case:
Was that intentional or just forgotten? |
This issue is bothers me too. Is there any chance this could be fixed in next 2.2.xx version? |
@martin654 This issue had been fixed in the JSF 2.2.14 and 2.3.2 |
@xinyuan-zhang: I'm using 2.2.14 and I can still reproduce the bug there. Either it hasn't been fixed in this version or the fix doesn't work. |
@jensberke Hi, Can you provide a test war application for this bug? |
@xinyuan-zhang thank you for quick reply. I am not sure it is fixed. I have very simple app with following page and composite and it is still not working with mojarra 2.2.14 (Myfaces works) Page:
Composite:
Bean:
|
@xinyuan-zhang: yes, but I've got no time for it right now. Probably tomorrow or the day after. |
@xinyuan-zhang: I managed to find some time to create a war file, see mojarra-issue-4244.zip |
Hi, it has been a while now, is there any progress on this issue? Thank You |
@xinyuan-zhang: Isn't the issue fixed in this changeset? I tested version 2.2.8-22 in my example and it works. I do not see the changes from 2.2.8-22 in the 2.2.14 version. It seems to me that it could be merged into 2.2.15... |
That change set is indeed in the 2_2 rolling branch and done a good while after 2.2.14 was released, so obviously it's not in 2.2.14. @xinyuan-zhang @ren-zhijun-oracle It's probably high time to do a 2.2.15 release cut as well. What do you think? |
Hi @arjantijms , Hi @martin654 , |
@xinyuan-zhang I saw it, thx! :) |
Hi @jensberke , |
Hi @xinyuan-zhang. I tested it and can confirm that it's fixed in 2.2.15. |
@xinyuan-zhang Thanks for 2.2.15 release, it works! |
I have a duplicate ID exception when using a composite component two times at same page.
Both components have different IDs.
One component is conditionally rendered with <c:if>, the other one isn't
I don't have this exception when doing exactly the same thing but using a plain JSF component instead.
I already asked at stackoverflow but got no answer:
http://stackoverflow.com/questions/42863043/duplicate-id-exception-when-using-cif-with-composite-component
Below the reproducer code:
A session scoped Bean: TestBean
A simple composite component: testCmp
A using page which allows switching between hide/show this component
When i switch between hide/show i get the exception:
"Component ID testForm:test2:text has already been found in the view"
When i don't use a composite component but a plain JSF component like e.g. <h:outputText> anything works well.
I tested with 2.2.14 and 2.3.0-m11
Affected Versions
[2.2.14, 2.3.0-m10]
The text was updated successfully, but these errors were encountered: