在模板中使用primefaces对话框重复id错误

时间:2013-08-27 14:33:32

标签: jsf-2 primefaces duplicates facelets

PF 3.5.10,Mojara 2.1.21,Omnifaces 1.5

我有带p:菜单的Facelet-Template和p:include for dialog

mytemplate.xhtml:

<h:form> ... <p:menubar> 
     <p:menuitem value="Start Dialog" oncomplete="mydialogwidget.show()"/>       
     <p:menuitem value="open another page" action="/app/mypage.xhtml?faces-redirect=true"/>
 </p:menubar>  ... </h:form>

<ui:insert name="content" />

<ui:include="/app/mydialog.xhtml" />

mydialog.xhtml:

<ui:composition> 
  <p:dialog widgetVar="mydialogwidget" ...>
    <h:form>
    <p:datatable binding="#{mybean.table}">
       <p:column id="col_first"> ... </p:column> 
         ...
       <p:column id="col_last"> ... </p:colum>
    </p:datatable>
    </h:form>
  </p:dialog>
</ui:composition>

mypage.xhtml:

 <ui:composition template="/app/mytemplate.xhtml">
    <ui:define name="content">
    <h:form> ... </h:form>
    </ui:define>
 </ui:composition>

如果我启动mypage.xhtml表单menue,我将成为JSF1007错误(重复ID)组件树将写入我的控制台。简化的组件树输出:

+id: mydialog
  +id: mytable
    +id: col_first  <<=============
     ....
    +id: col_last 
    +id:col_first <<========

mydialog.xhtml只会包含一次。问题JSF with Primefaces Menu duplicate Id error?的答案对我没有帮助。 我怎样才能避免这个错误?来自哪里的错误?

1 个答案:

答案 0 :(得分:3)

prolbem是datatable的绑定属性。另见:Binding attribute causes duplicate component ID found in the view

SessionScoped组件用于多个视图。

我使用了EL-table绑定,然后问题就消失了。