How to ajax-update the p:dataTable from inside the p:dataTable itself?

廉价感情. 提交于 2020-01-10 04:04:45

问题


<h:form id="formId">
   <p:wizard id="wizardId">
      <p:tab id="tabId">
         <p:dataTable id="tableId">
           <p:column>
             <h:commandLink value="remove" update=""/>
           </p:column>
         </p:dataTable>
      </p:tab>
   </p:wizard>
</h:form>

I need to update only the <p:dataTable> without the entire form. I tried using @form, @parent, :formId:wizardId:tabId:tableId, but none of them are working as I want. When I use @form, it is checking for validation which I don't need to do.

How can I achieve this?


回答1:


First of all, this will indeed never work with a <h:commandLink>, simply because it doesn't support the update attribute at all. Perhaps you actually meant to use <p:commandLink>?

Once you've fixed the <h:commandLink> being a <p:commandLink>, then head to this answer: How to find out client ID of component for ajax update/render? Cannot find component with expression "foo" referenced from "bar" to learn how to reference components in JSF ajax.

After having read that answer, you should have found out that the datatable is in this particular code snippet identified by :formId:tableId. So, all with all, the following should do:

<p:commandLink value="remove" update=":formId:tableId" />

Note that there's until with PrimeFaces 3.3 a bug in ajax-updating of the <p:dataTable> in certain complex UI compositions. This is fixed in PrimeFaces 3.4. If you encounter exactly this problem and can't upgrade to PrimeFaces 3.4, then you'd need to wrap the table in some <h:panelGroup id="tablePanelId"> and then use update=":formId:tablePanelId" instead.



来源:https://stackoverflow.com/questions/12516397/how-to-ajax-update-the-pdatatable-from-inside-the-pdatatable-itself

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