简体   繁体   中英

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM