PrimeFaces 从对话更新单行数据表
PrimeFaces update single row of datatable from dialogue
我有一个要求,我在数据中使用 rowExpensiontable。
这会打开另一个数据table(sub table)。
在 sub table 下面我有一个编辑按钮。
单击“编辑”后,它会打开模型对话框,一旦我单击“保存”,它就会关闭对话框,但我无法找到更新该特定子 table 的方法。
下面是子table&对话的代码片段。谁能建议我一种方法来更新单击编辑按钮的特定 subtable。
<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>
RequestContext.getCurrentInstance().update("form:something:" + index + "something");
这对我有用。
"update" 属性不带 运行 时间表达式值。
要更新数据表中的特定行,您可以使用 RequestContext 更新特定组件,因此请从命令按钮中删除更新表达式,并将其添加到您的 setAgentCodeInParties 方法中:
RequestContext.getCurrentInstance().update(
s.getClientId(FacesContext.getCurrentInstance())
+ ":" + event.getRowIndex()
+ ":***"
);
我有一个要求,我在数据中使用 rowExpensiontable。 这会打开另一个数据table(sub table)。 在 sub table 下面我有一个编辑按钮。 单击“编辑”后,它会打开模型对话框,一旦我单击“保存”,它就会关闭对话框,但我无法找到更新该特定子 table 的方法。
下面是子table&对话的代码片段。谁能建议我一种方法来更新单击编辑按钮的特定 subtable。
<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>
RequestContext.getCurrentInstance().update("form:something:" + index + "something");
这对我有用。 "update" 属性不带 运行 时间表达式值。
要更新数据表中的特定行,您可以使用 RequestContext 更新特定组件,因此请从命令按钮中删除更新表达式,并将其添加到您的 setAgentCodeInParties 方法中:
RequestContext.getCurrentInstance().update(
s.getClientId(FacesContext.getCurrentInstance())
+ ":" + event.getRowIndex()
+ ":***"
);