I have a lazily-loaded datatable with records, each of which contains a list of tags (keywords). I want to be able to remove/add a tag to any of the records, and update only the single record (the list of tags -- "refTagsList" below) as opposed to reloading the entire datatable page. Is this possible?
This is what I have so far (which doesn't work):
Code: Select all
<h:form id="refs">
<p:outputPanel id="referencesAll">
<p:dataTable id="referenceList" var="reference" value="#{referencesAllBean.references}"
paginator="true" rows="5" paginatorTemplate="{CurrentPageReport}
{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink}
{LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5,10,15"
paginatorPosition="bottom" lazy="true">
<p:column>
<h:outputText value="#{reference.title}" style="font-weight:bold;"/>
<br/>
<ui:repeat value="#{reference.authors}" var="author" varStatus="status">
<h:outputText value="#{author.authorLName}"/>
<h:outputText value="#{author.authorFName}"/>
<h:outputText value="#{author.authorMName}"/>
<h:outputText value=", " rendered="#{!status.last}" />
</ui:repeat>
<br/>
<h:outputText value="#{reference.journal.journalName}" rendered="#{reference.type == 'JournalReference'}"/>,
<h:outputText value="#{reference.pubDate}"/>
<br/>
<h:outputLabel for="tags" value="Tags: " />
<p:outputPanel id="refTagsList">
<ui:repeat value="#{reference.tags}" var="tag" varStatus="status">
<h:outputText value="#{tag.tag}"/>
<p:spacer width="2px"/>
<p:commandLink action="removeTag" actionListener="#{reference.removeTag}" update=":refs:refTagsList">
<f:attribute name="index" value="#{status.index}" />
<f:setPropertyActionListener value="#{reference}" target="#{referencesAllBean.selectedReference}" />
<p:graphicImage url="/images/delete_BW.png"
style="width: 10px; height: 10px;" />
</p:commandLink>
<p:spacer width="7px"/>
</ui:repeat>
<p:commandLink title="Edit tags" update="refTags" oncomplete="tagsDialog.show()" value="Add Tag">
<f:setPropertyActionListener value="#{reference}" target="#{referencesAllBean.selectedReference}" />
</p:commandLink>
</p:outputPanel>
</p:column>
</p:dataTable>
</p:outputPanel>
</h:form>
T.