Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
953 views
in Technique[技术] by (71.8m points)

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...