2

I have a main HTML page which includes detail.xhtml and duo.xhtml.

Now duo.xhtml also includes detail.xhtml, which results in duplicate IDs which of course it not working. What can I do to solve this problem? I don't want to manage redundant code.

Main:

<ui:composition ...>
  <ui:define name="center">
    <ui:insert name="insertDuo">
      <ui:include src="/includes/duo.xhtml" />
    </ui:insert>
...
<p:dialog header="x" widgetVar="detDialog" id="dlg" modal="true" appendTo="@(body)">
  <ui:insert name="insertDetail">
    <ui:include src="/includes/detail.xhtml" />
  </ui:insert>

Duo:

<ui:composition>
    <p:dialog header="y" widgetVar="newDuoDialog" id="newDuoDlg" modal="true" >
        <p:layout id="layout">

            <p:layoutUnit position="west">
                <ui:insert name="insertDetailStmt">
                    <h:form id="stmtDetailForm">
                        <ui:include src="/includes/detail.xhtml" />
                    </h:form>
                </ui:insert>
            </p:layoutUnit>

Detail:

<p:accordionPanel id="accordion">

Reference to components:

<p:commandButton value="z" update=":accordion:duoDlgForm2:pickList"/>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
dasLort
  • 1,264
  • 1
  • 13
  • 28
  • and how would my ``s for example refer to the `` ? I think your second sentences lacks detail. I can't understand what you advise me to do exactly – dasLort Mar 24 '14 at 15:27
  • I heavily disagree with @DarkFalcon since looks he has not worked with JSF before. Anyway, seems like you're not prepending the ID from the container e.g. ``, ``; or you're effectively using duplicate IDs in both pages, so just change them. It would be better if you provide a code sample. – Luiggi Mendoza Mar 24 '14 at 15:28
  • 1
    @LuiggiMendoza: Correct, in fact, I didn't see the tag. I saw xhtml and assumed HTML IDs. My apologies. – Dark Falcon Mar 24 '14 at 15:35
  • @DarkFalcon in the end, JSF will generate plain HTML. The problem is how you define the HTML generation, and nobody can save you from telling your code to generate a `
    ` inside another `
    ` and making your page never firing a request :) (but that's outside the scope of this question).
    – Luiggi Mendoza Mar 24 '14 at 15:37
  • @LuiggiMendoza yes, I am using duplicate IDs because it refers to the same page. I cannot simply change them, the effect was still the same – dasLort Mar 24 '14 at 16:15
  • 1
    Duplicate of [Avoiding duplicate ids when reusing facelets compositions in the same naming container](http://stackoverflow.com/questions/21552654/avoiding-duplicate-ids-when-reusing-facelets-compositions-in-the-same-naming-con) – BalusC Mar 24 '14 at 17:35

1 Answers1

5

Thanks to BalusC, I was able to solve the problem. Just use

<f:subview id="fromMain">
    <ui:include src="/includes/regelDetail.xhtml" />
</f:subview>

and when referred from main, the element's name is fromMain:accordion

dasLort
  • 1,264
  • 1
  • 13
  • 28