Topic
  • 14 replies
  • Latest Post - ‏2013-04-06T10:25:42Z by paoloc
SystemAdmin
SystemAdmin
6195 Posts

Pinned topic Error "Duplicate component found in view"

‏2010-07-23T10:45:44Z |
Hello,
in a JSF/EGL project a button invoking a pagehandler results in the error javax.servlet.jsp.JspException: Duplicate component ID 'form1:_id0' found in view.

Googling solutions to this error suggests explicitly giving an id to all JSF components but was not the case here as all components in the form have an explicitly defined ID. How can I find out which component causes the trouble and why? Could it be an EGL variable stored in bean and if so, which variable and why it is duplicated? Tomcat log does not give any clues and neither does debugging the related EGL code. The same code performs OK in RAD 6, but the code migrated to 7.5 (or 7.5.1.4 to be exact) gives these errors. Where to start troubleshooting?

As a perhaps related note, I assume that handling the beans is somehow different in RBD7 than it was in RAD6 as in the latter something like <input type="hidden" name="com.sun.faces.VIEW" id="com.sun.faces.VIEW" value="_id21:_id23" /> is appended to every form RBD7 (unlike in RAD6). Does this have any implications to the programmer - anything that should be done differently now?
Updated on 2013-04-06T10:25:42Z at 2013-04-06T10:25:42Z by paoloc
  • jspadea
    jspadea
    156 Posts

    Re: Error "Duplicate component found in view"

    ‏2010-07-26T13:03:31Z  
    I've seen this a couple years ago, and I think in my application the problem boiled down to the f:selectItem and f:selectItems tags not including unique IDs, therefore they got autogenerated IDs and that caused a duplicate (it tries to avoid duplicates, but I guess there are situations where it can't be prevented). Adding unique IDs to all such tags in the JSP fixed it for me.

    -Justin
  • SystemAdmin
    SystemAdmin
    6195 Posts

    Re: Error "Duplicate component found in view"

    ‏2010-07-27T06:57:11Z  
    • jspadea
    • ‏2010-07-26T13:03:31Z
    I've seen this a couple years ago, and I think in my application the problem boiled down to the f:selectItem and f:selectItems tags not including unique IDs, therefore they got autogenerated IDs and that caused a duplicate (it tries to avoid duplicates, but I guess there are situations where it can't be prevented). Adding unique IDs to all such tags in the JSP fixed it for me.

    -Justin

    Hello,
    thank you for the suggestion. I double-checked all component definitions and they all have a unique id. In the generated HTML the <select> item has unique ID but the individual options derived from <f:selectItems id="myUniqueID" value="#{myListArray.toArray}"> do not have ID's. However, that does not seem the issue since the same error happens when <h:selectOneMenu> is replaced with <h:inputText>.
    Rather, the error seems to happen only when the value of some other fields are empty when the form is submitted. The curious thing is that this is the only jsp page that generates the error when a form with empty fiels is submitted (and those fields certainly have a unique id). I strongly suspect that it is those empty fields that are doubly generated (because leaving the first empty results in Duplicate component ID 'form1:_id0' and leaving the following one empty results in Duplicate component ID 'form1:_id2'). It is puzzling why this happens in this particular page but not in the dozens and dozens of other pages we have.
  • SystemAdmin
    SystemAdmin
    6195 Posts

    Re: Error "Duplicate component found in view"

    ‏2010-07-27T07:05:24Z  

    Hello,
    thank you for the suggestion. I double-checked all component definitions and they all have a unique id. In the generated HTML the <select> item has unique ID but the individual options derived from <f:selectItems id="myUniqueID" value="#{myListArray.toArray}"> do not have ID's. However, that does not seem the issue since the same error happens when <h:selectOneMenu> is replaced with <h:inputText>.
    Rather, the error seems to happen only when the value of some other fields are empty when the form is submitted. The curious thing is that this is the only jsp page that generates the error when a form with empty fiels is submitted (and those fields certainly have a unique id). I strongly suspect that it is those empty fields that are doubly generated (because leaving the first empty results in Duplicate component ID 'form1:_id0' and leaving the following one empty results in Duplicate component ID 'form1:_id2'). It is puzzling why this happens in this particular page but not in the dozens and dozens of other pages we have.
    One thing to be looked at. Besides the static page content in JSP. Does the handler do any dynamic construction of page elements? For example, is there a function that creates a new form with a fixed ID assigned.
  • SystemAdmin
    SystemAdmin
    6195 Posts

    Re: Error "Duplicate component found in view"

    ‏2010-07-27T09:05:23Z  
    One thing to be looked at. Besides the static page content in JSP. Does the handler do any dynamic construction of page elements? For example, is there a function that creates a new form with a fixed ID assigned.

    The data is bound to various fields in a basicRecord that is empty when page is initially loaded. There are dynamically constructed page elements in the sense that they are fetched from the database (based on the fields that cause trouble when empty). However, none of these should be re-rendered when the form is submitted, as only the following action is executed (just the bare bones for debugging purposes).
    function myButtonAction()
    if (myInputField == "")
    SysLib.writeStdout("Input field empty");
    return;
    end
    Removing components one by one revealed that the error could be removed by removing a <h:outputText> component that is bound to a field in the same basicRecord as all the other components. However, I doubt that this is the real culprit since (1) it has uniquely defined ID and (2) its rendered property is set to false.
  • paoloc
    paoloc
    525 Posts

    Re: Error "Duplicate component found in view"

    ‏2013-04-03T14:47:09Z  

    The data is bound to various fields in a basicRecord that is empty when page is initially loaded. There are dynamically constructed page elements in the sense that they are fetched from the database (based on the fields that cause trouble when empty). However, none of these should be re-rendered when the form is submitted, as only the following action is executed (just the bare bones for debugging purposes).
    function myButtonAction()
    if (myInputField == "")
    SysLib.writeStdout("Input field empty");
    return;
    end
    Removing components one by one revealed that the error could be removed by removing a <h:outputText> component that is bound to a field in the same basicRecord as all the other components. However, I doubt that this is the real culprit since (1) it has uniquely defined ID and (2) its rendered property is set to false.
    Have You solved this problem?

    I have same problem unresolved.

    paoloc
  • SystemAdmin
    SystemAdmin
    6195 Posts

    Re: Error "Duplicate component found in view"

    ‏2013-04-03T19:24:56Z  
    • paoloc
    • ‏2013-04-03T14:47:09Z
    Have You solved this problem?

    I have same problem unresolved.

    paoloc
    Our problems were mostly related to the differences between RAD6 and RBD 7.5. In addition, we had severe problems with page beans being cancelled which was fixed in PM21238 (included in RBD 7.5.1.7. RBD 8.5 should have that fix (and I am not even sure if it applies to you).

    Unfortunately, it was almost three years ago and I do not remember details. As I mentioned in the other thread, a colleague of mine had similar issues that apparently resulted in from the different life cycles of JSP and JSF. We were able to identify the component that was causing it and, if I recall correctly, we enclosed that component inside a jsp panel. That is something you might try. It is tedious, but I cannot give a better suggestion.
  • paoloc
    paoloc
    525 Posts

    Re: Error "Duplicate component found in view"

    ‏2013-04-04T07:28:40Z  
    Our problems were mostly related to the differences between RAD6 and RBD 7.5. In addition, we had severe problems with page beans being cancelled which was fixed in PM21238 (included in RBD 7.5.1.7. RBD 8.5 should have that fix (and I am not even sure if it applies to you).

    Unfortunately, it was almost three years ago and I do not remember details. As I mentioned in the other thread, a colleague of mine had similar issues that apparently resulted in from the different life cycles of JSP and JSF. We were able to identify the component that was causing it and, if I recall correctly, we enclosed that component inside a jsp panel. That is something you might try. It is tedious, but I cannot give a better suggestion.
    Following your advice, I have done so:
    My jsp has 3 tabbed pannels bfpanel1,bfpanel2 and bfpanel3:
    1) Deleting bfpanel2 and bfpanel3 and working only with bfpanel1 NO error
    So the problem is with the fields on bfpanel2 and bfpanel3.
    2) I deleted one by one all the fields in bfpanel2 and bfpanel3 with same error.
    So the problem is in the panels no in their fields !!!
    How to do?

    Desperate paoloc
  • dan_darnell
    dan_darnell
    973 Posts

    Re: Error "Duplicate component found in view"

    ‏2013-04-04T17:23:08Z  
    • paoloc
    • ‏2013-04-04T07:28:40Z
    Following your advice, I have done so:
    My jsp has 3 tabbed pannels bfpanel1,bfpanel2 and bfpanel3:
    1) Deleting bfpanel2 and bfpanel3 and working only with bfpanel1 NO error
    So the problem is with the fields on bfpanel2 and bfpanel3.
    2) I deleted one by one all the fields in bfpanel2 and bfpanel3 with same error.
    So the problem is in the panels no in their fields !!!
    How to do?

    Desperate paoloc
    It has been a long time since I worked daily with JSF (we only have one app in production that is still JSF -- everything else is RUI now) but I looked at how I did tabbed panels in that JSF app. I recall having all sorts of issues until I added JSP panels to the mix. All of my panels are structured like this:
    <odc:bfPanel id="bfpanel2" name="#{viewOrders.VOzTab3}" showFinishCancelButton="false" rendered="#{viewOrders.allowed}">
    <h:panelGroup id="group3" styleClass="panelGroup">
    <hx:jspPanel id="jspPanel0">
    A JSP panel within a panel group within a bfPanel. Adding JSP panel to the mix definitely solved the problems I was having (just too long ago for me to remember exactly what those problems were...sorry).

    Originally we ran the JSF app on Tomcat 5.x and now it is hosted on 7.x. We did some testing once upon a time with Tomcat 6.x and were never able to get everything stable enough to transition our production environment to that version. We ended up waiting until Tomcat 7 was released and just skipped 6 altogether. Again, too long ago for me to remember what those issues were with 6 exactly but they were severe enough that we just gave up and stayed on 5 until 7 was available.

    Sincerely hope this helps...

    --Dan
  • SystemAdmin
    SystemAdmin
    6195 Posts

    Re: Error "Duplicate component found in view"

    ‏2013-04-04T18:44:54Z  
    It has been a long time since I worked daily with JSF (we only have one app in production that is still JSF -- everything else is RUI now) but I looked at how I did tabbed panels in that JSF app. I recall having all sorts of issues until I added JSP panels to the mix. All of my panels are structured like this:
    <odc:bfPanel id="bfpanel2" name="#{viewOrders.VOzTab3}" showFinishCancelButton="false" rendered="#{viewOrders.allowed}">
    <h:panelGroup id="group3" styleClass="panelGroup">
    <hx:jspPanel id="jspPanel0">
    A JSP panel within a panel group within a bfPanel. Adding JSP panel to the mix definitely solved the problems I was having (just too long ago for me to remember exactly what those problems were...sorry).

    Originally we ran the JSF app on Tomcat 5.x and now it is hosted on 7.x. We did some testing once upon a time with Tomcat 6.x and were never able to get everything stable enough to transition our production environment to that version. We ended up waiting until Tomcat 7 was released and just skipped 6 altogether. Again, too long ago for me to remember what those issues were with 6 exactly but they were severe enough that we just gave up and stayed on 5 until 7 was available.

    Sincerely hope this helps...

    --Dan
    I have not used tabbed panels, but I would have suggested similar thing as Dan: make sure that non-JSF components are embedded inside a hx:jspPanel component.

    I also perused our repository to find the case my colleague had. If I recall correctly, he had a similar issue with duplicate ids. He solved it by embedding a hx:jspPanel component inside a f:subview component. When I found the file, it was easy to identify based on the id in the tag <f:subview id="kludge1">. In our parlance it means that f:subview component had no real functionality; it was added just to solve the id issue.
  • dan_darnell
    dan_darnell
    973 Posts

    Re: Error "Duplicate component found in view"

    ‏2013-04-04T19:36:17Z  
    I have not used tabbed panels, but I would have suggested similar thing as Dan: make sure that non-JSF components are embedded inside a hx:jspPanel component.

    I also perused our repository to find the case my colleague had. If I recall correctly, he had a similar issue with duplicate ids. He solved it by embedding a hx:jspPanel component inside a f:subview component. When I found the file, it was easy to identify based on the id in the tag <f:subview id="kludge1">. In our parlance it means that f:subview component had no real functionality; it was added just to solve the id issue.
    <f:subview id="kludge1">

    LOL. Love it!
  • paoloc
    paoloc
    525 Posts

    Re: Error "Duplicate component found in view"

    ‏2013-04-05T08:43:35Z  
    I have not used tabbed panels, but I would have suggested similar thing as Dan: make sure that non-JSF components are embedded inside a hx:jspPanel component.

    I also perused our repository to find the case my colleague had. If I recall correctly, he had a similar issue with duplicate ids. He solved it by embedding a hx:jspPanel component inside a f:subview component. When I found the file, it was easy to identify based on the id in the tag <f:subview id="kludge1">. In our parlance it means that f:subview component had no real functionality; it was added just to solve the id issue.
    Hi,

    Using Tomcat 7 give the same error
    and also the structure proposed by Dan

    I want to try <f:subview> but do not know where to put.
    I have the following structure (all jsp attached):

    <h:panelGroup styleClass="panelGroup" id="group1">
    <hx:jspPanel id="jspPanel1">
    <table width="100%" border="1" id="generale">
    <tbody><tr><td>

    <odc:tabbedPanel slantInactiveRight="4" width="100%"
    styleClass="tabbedPanel" height="100%" slantActiveRight="4" showBackNextButton="false"
    id="tabbedPanel1" showTabs="true" variableTabLength="false" >

    <odc:bfPanel id="bfpanel1" name="Spazio di lavoro" showFinishCancelButton="false" >

    <table width="100%" border="1" id="Spaziodilavoro"><tbody><tr><td>

    • *
    <h:panelGroup styleClass="panelGroup" id="gUtente">

    <table width="100%" border="1" id="Spaziodilavoro"></td></tr></tbody></table>
    *<tbody> <tr><td> *
    <h:selectOneMenu styleClass="selectOneMenu"
    id="menu1" value="#{spazioDiLavoro3.codtutti}" binding="#{spazioDiLavoro3.codtutti_Ref}">
    <f:selectItems
    value="#{selectitems.spazioDiLavoro3.ger.cognome.codiceute.toArray}" />
    </h:selectOneMenu><hx:behavior event="onchange"
    target="menu1" behaviorAction="get;get;get;get"
    targetAction='gCartelle;gDocumenti;gCondivisioni;gUtente'></hx:behavior>
    </td></tr></tbody></table>
    <tr><td>
    <td><table width="100%" border="1" id="t2">
    <tbody><tr>
    <td>
    <h:panelGroup styleClass="panelGroup" id="gCartelle">
    <hx:jspPanel id="jCartelle"> <hx:dataTableEx id="tableEx1"
    .......
    <(h:panelGroup>
    </td>
    <td>
    <h:panelGroup styleClass="panelGroup" id="gDocumenti">
    <hx:dataTableEx id="tableEx2">
    <tbody> <tr><td>
    .....
    </hx:dataTableEx></td></tr></tbody></table></td></tr>

    where enter <f:subview id="xx"> and </f:subview> ?

    paoloc
  • SystemAdmin
    SystemAdmin
    6195 Posts

    Re: Error "Duplicate component found in view"

    ‏2013-04-05T11:28:12Z  
    • paoloc
    • ‏2013-04-05T08:43:35Z
    Hi,

    Using Tomcat 7 give the same error
    and also the structure proposed by Dan

    I want to try <f:subview> but do not know where to put.
    I have the following structure (all jsp attached):

    <h:panelGroup styleClass="panelGroup" id="group1">
    <hx:jspPanel id="jspPanel1">
    <table width="100%" border="1" id="generale">
    <tbody><tr><td>

    <odc:tabbedPanel slantInactiveRight="4" width="100%"
    styleClass="tabbedPanel" height="100%" slantActiveRight="4" showBackNextButton="false"
    id="tabbedPanel1" showTabs="true" variableTabLength="false" >

    <odc:bfPanel id="bfpanel1" name="Spazio di lavoro" showFinishCancelButton="false" >

    <table width="100%" border="1" id="Spaziodilavoro"><tbody><tr><td>

    • *
    <h:panelGroup styleClass="panelGroup" id="gUtente">

    <table width="100%" border="1" id="Spaziodilavoro"></td></tr></tbody></table>
    *<tbody> <tr><td> *
    <h:selectOneMenu styleClass="selectOneMenu"
    id="menu1" value="#{spazioDiLavoro3.codtutti}" binding="#{spazioDiLavoro3.codtutti_Ref}">
    <f:selectItems
    value="#{selectitems.spazioDiLavoro3.ger.cognome.codiceute.toArray}" />
    </h:selectOneMenu><hx:behavior event="onchange"
    target="menu1" behaviorAction="get;get;get;get"
    targetAction='gCartelle;gDocumenti;gCondivisioni;gUtente'></hx:behavior>
    </td></tr></tbody></table>
    <tr><td>
    <td><table width="100%" border="1" id="t2">
    <tbody><tr>
    <td>
    <h:panelGroup styleClass="panelGroup" id="gCartelle">
    <hx:jspPanel id="jCartelle"> <hx:dataTableEx id="tableEx1"
    .......
    <(h:panelGroup>
    </td>
    <td>
    <h:panelGroup styleClass="panelGroup" id="gDocumenti">
    <hx:dataTableEx id="tableEx2">
    <tbody> <tr><td>
    .....
    </hx:dataTableEx></td></tr></tbody></table></td></tr>

    where enter <f:subview id="xx"> and </f:subview> ?

    paoloc
    Basically I can see only three options: enclose tab group, enclose individual tabs or enclose contents of each tab. This is a stab in the dark but since you already identified that the tabs are causing duplicate ids, you might enclose tabs inside f:subview. But it should not take too much work to try each of the three.

    I looked at the jsp code. I am not familiar with odc-components and their specifics. I would be interested to know they can contain HTML tags. According to the documentation "Most Faces components can contain other Faces tags but not HTML tags. However, this jspPanel component can contain both Faces and HTML tags." A variant of Dan's advice would be the following structure:
    <odc:tabbedPanel>
      <odc:bfPanel>
        <hx:jspPanel>
              <html tags>
                <jsf tag>
    
    Tag <hx:jspPanel> looks like redundant here, but I did not find any docs stating whether you can put html inside <odc:bfPanel>. If that does not help, you might try using subview in all three possible positions.
    Updated on 2014-03-25T04:35:19Z at 2014-03-25T04:35:19Z by iron-man
  • paoloc
    paoloc
    525 Posts

    Re: Error "Duplicate component found in view"

    ‏2013-04-05T13:57:40Z  
    Basically I can see only three options: enclose tab group, enclose individual tabs or enclose contents of each tab. This is a stab in the dark but since you already identified that the tabs are causing duplicate ids, you might enclose tabs inside f:subview. But it should not take too much work to try each of the three.

    I looked at the jsp code. I am not familiar with odc-components and their specifics. I would be interested to know they can contain HTML tags. According to the documentation "Most Faces components can contain other Faces tags but not HTML tags. However, this jspPanel component can contain both Faces and HTML tags." A variant of Dan's advice would be the following structure: <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr"><odc:tabbedPanel> <odc:bfPanel> <hx:jspPanel> <html tags> <jsf tag> </pre> Tag <hx:jspPanel> looks like redundant here, but I did not find any docs stating whether you can put html inside <odc:bfPanel>. If that does not help, you might try using subview in all three possible positions.
    I'm sorry I do not understand where to insert <subview> in your example.
    I found that:
    To include another JSP or JSF page, using <jsp:include> or <c:import>, we must use <f:subview> tag around it so that JSF process the included file properly.

    But I not have any <jsp:include> nor <c:import> in the page.
    In Your structure:
    <odc:tabbedPanel>
    <odc:bfPanel>
    <hx:jspPanel>
    <html tags>
    <jsf tag>
    can You insert all possible <subview> ? (You say: in all three possible positions)
    I come from RPG and ibm had promised me that I would use egl without knowing anything about java, javascrupt, html, etc.
    That was a lie as usual. Not only that, using only drag and drop things in EGL do not work always.
    I need to fix it, otherwise I have to rewrite this jsp and divide it into 3 jsp instead of three tabbedPanel.
    Which safe alternative do you propose?
    paoloc
  • paoloc
    paoloc
    525 Posts

    Re: Error "Duplicate component found in view"

    ‏2013-04-06T10:25:42Z  
    Basically I can see only three options: enclose tab group, enclose individual tabs or enclose contents of each tab. This is a stab in the dark but since you already identified that the tabs are causing duplicate ids, you might enclose tabs inside f:subview. But it should not take too much work to try each of the three.

    I looked at the jsp code. I am not familiar with odc-components and their specifics. I would be interested to know they can contain HTML tags. According to the documentation "Most Faces components can contain other Faces tags but not HTML tags. However, this jspPanel component can contain both Faces and HTML tags." A variant of Dan's advice would be the following structure: <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr"><odc:tabbedPanel> <odc:bfPanel> <hx:jspPanel> <html tags> <jsf tag> </pre> Tag <hx:jspPanel> looks like redundant here, but I did not find any docs stating whether you can put html inside <odc:bfPanel>. If that does not help, you might try using subview in all three possible positions.
    Found,found,found!!!! (after 3 days of frustrating job)
    The message "Duplicate component found in view" is wrong (muddler,incorrect....).
    The error occurs when there are more Combobox in the same JSP.
    Inserting <f:subview id="XX"> the problem disappears.
    Example:

    <f:subview id="a6">
    <h:selectOneMenu styleClass="selectOneMenu"
    id="menu34" value="#{spazioDiLavoro3.fornitoreselezionato}"
    binding="#{spazioDiLavoro3.fornitoreselezionato_Ref}">
    <f:selectItems
    value="#{selectitems.spazioDiLavoro3.fornitori.CLRAGCLI.CLCODCLI.toArray}" />
    </h:selectOneMenu>
    </f:subview>

    Is an error in Tomcat7 or EGL?
    This issue must be absolutely correct and reported by IBM.
    Please do not say more than I not need to know html or javascript or .....

    paoloc