JSF包含并复制HTML ID

时间:2014-03-24 15:18:11

标签: jsf include facelets

我有一个主HTML页面,其中包含 detail.xhtml duo.xhtml

现在 duo.xhtml 还包含 detail.xhtml ,这会导致重复的ID,当然它不起作用。我该怎么做才能解决这个问题?我不想管理多余的代码。

主:

<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>

朵:

<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>

详情:

<p:accordionPanel id="accordion">

参考组件:

<p:commandButton value="z" update=":accordion:duoDlgForm2:pickList"/>

1 个答案:

答案 0 :(得分:3)

感谢BalusC,我能够解决问题。只需使用

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

当从main引用时,元素的名称是 fromMain:accordion