Duplicate id error with primefaces dialog in template

六月ゝ 毕业季﹏ 提交于 2019-12-11 13:12:19

问题


PF 3.5.10, Mojara 2.1.21, Omnifaces 1.5

I have Facelet-Template with p:menu and 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>

If I start mypage.xhtml form menue, I become JSF1007 error (Duplicate ids) The component tree will be written to my console. The simplified component tree output:

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

The mydialog.xhtml will be included only once. The answer to question JSF with Primefaces Menu duplicate Id error? doesn't help me. How can I aviod this error ? Where comes this error from ?


回答1:


The prolbem was binding attribute on datatable. See also: Binding attribute causes duplicate component ID found in the view

SessionScoped component was used in multiple views.

I've used EL-table binding and then the problem was disappeared.



来源:https://stackoverflow.com/questions/18468378/duplicate-id-error-with-primefaces-dialog-in-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!