I have a requirement where I am using rowExpension inside a datatable. which opens another datatable(sub table). Below sub table I have one edit button. upon clicking edit it opens model dialogue and once I click save it closes the dialogue but I am not able to find a way to update that particular sub table.
Below is the code snippet of subtable & dialogue. Can anybody suggest me a way to update the particular subtable for which the edit button is clicked.
<p:rowExpansion id="partyRows">
<p:dataTable
var="party"
value="#{pocAccountBean.parties}"
rows="20"
id="test"
widgetVar="partyTable"
resizableColumns="true"
emptyMessage="No associated parties found."
rowIndexVar="idx"
styleClass="testClass_#{account.accountNbr}">
<p:column headerText="Party Name" sortBy="#{party.partyKey}">
<h:outputText value="#{party.partyKey}" />
</p:column>
<p:column headerText="Party Type" sortBy="#{party.partyType}">
<h:outputText value="#{party.partyType}" />
</p:column>
<p:column headerText="Agent Code" sortBy="#{party.agentCode}">
<h:outputText value="#{party.agentCode}"/>
</p:column>
<p:column headerText="Party Status" sortBy="#{party.partyStatus}">
<h:outputText value="#{party.partyStatus}" />
</p:column>
<p:column headerText="Education Level" sortBy="#{party.educationLevel}">
<h:outputText value="#{party.educationLevel}" />
</p:column>
<p:column headerText="Current Date" sortBy="#{party.currentDate}">
<h:outputText value="#{party.currentDate}" />
</p:column>
</p:dataTable>
<h:panelGrid columns="1" cellpadding="5" border="0">
<p:commandButton value="Edit" type="button" onclick="PF('dlg2').show();"/>
</h:panelGrid>
<p:dialog header="Terms" widgetVar="dlg2" modal="true" height="400" width="800" id="d1" dynamic="true">
<h:inputText value="#{pocAccountBean.agentCode}" />
<p:commandButton action="#{pocAccountBean.setAgentCodeInParties()}" value="Save" onclick="PF('dlg2').hide();" update="@(.testClass_#{account.accountNbr})"></p:commandButton>
</p:dialog>
</p:rowExpansion>
This is what worked for me. "update" attribute does not take run time expression value.
To update a specific row in datatable you can use RequestContext to update specific component, so remove the update expression from your commandButton, and add this to your setAgentCodeInParties method: