我有问题。我使用组件treeTable,我需要动态更新它。当我使用<p:poll>
时,它会完全更新,但我只需要更新值。我不想要,例如,更新后,treeTable大小的列被重置为默认值。
<p:treeTable id="treeTable" value="#{kpiController.root}"
var="kpiModel" resizableColumns="true" minSize="300" >
<f:facet name="header">Kpi Statistics</f:facet>
<p:column style="text-align: left; width: 25%">
<f:facet name="header">#{kpiController.header[0]}</f:facet>
<p:graphicImage url="images/Node.png" rendered="#{kpiModel.type eq 'StatisticsNode'}"/>
<p:graphicImage url="images/Statistic.png" rendered="#{kpiModel.type eq 'StatisticsItem'}"/>
<p:graphicImage url="images/Treshold2.png" rendered="#{kpiModel.type eq 'ThresholdItem'}"/>
#{kpiModel.indicator}
</p:column>
<p:column id="kpiValue" style="width:7%">
<f:facet name="header">#{kpiController.header[1]}</f:facet>
#{kpiModel.value}
</p:column>
<p:column style="width: 38%">
<f:facet name="header">#{kpiController.header[2]}</f:facet>
#{kpiModel.parameters}
</p:column>
<p:column style="width: 10%">
<f:facet name="header">#{kpiController.header[3]}</f:facet>
<p:selectBooleanCheckbox value="#{kpiModel.monitor}"
rendered="#{kpiModel.type ne 'StatisticsNode' and
kpiModel.type ne 'ThresholdItem'}"/>
</p:column>
<p:column style="width: 8%">
<f:facet name="header">#{kpiController.header[4]}</f:facet>
#{kpiModel.user}
</p:column>
<p:column style="width: 10%">
<f:facet name="header">#{kpiController.header[5]}</f:facet>
#{kpiModel.server}
</p:column>
<p:column style="width: 2%">
<p:commandLink update=":form:detailPanel" oncomplete="detailDialog.show()"
title="View Detail" styleClass="ui-icon ui-icon-search"
rendered="#{kpiModel.type ne 'StatisticsNode'}">
<f:setPropertyActionListener value="#{kpiModel}"
target="#{kpiController.selectedModel}" />
</p:commandLink>
</p:column>
</p:treeTable>
public class KpiController implements Serializable {
private static Logger logger = Logger.getLogger("core");
private String name = "Kpi Statistic";
private TreeNode root;
private List<String> header;
private WebStatisticsService kpiService = WebStatisticsService.getInstance();
private KpiModel selectedModel;
public KpiController() {
root = kpiService.getTreeRoot();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<String> getHeader() {
header = new ArrayList <String>();
header.add(Localization.getString("Statistics.column.colStatistics.text"));
header.add(Localization.getString("Statistics.column.colValue.text"));
header.add(Localization.getString("client.statistics.dialog.params.text"));
header.add(Localization.getString("client.statistics.monitor"));
header.add(Localization.getString("client.statistics.user"));
header.add(Localization.getString("client.statistics.owner"));
return header;
}
public void logout() {
try {
FacesContext.getCurrentInstance().getExternalContext().redirect("/logout");
}catch(IOException e) {
logger.warn("Cannot logout " + e.getCause());
}
}
public void login() throws IOException {
try {
FacesContext.getCurrentInstance().getExternalContext().redirect("index.xhtml");
}catch (IOException e) {
logger.warn("Cannot redirect to index.xhtml " + e.getCause());
}
}
public TreeNode getRoot() {
root = kpiService.getTreeRoot();
return root;
}
public void setRoot(TreeNode root) {
this.root = root;
}
public KpiModel getSelectedModel() {
return selectedModel;
}
public void setSelectedModel(KpiModel selectedModel) {
this.selectedModel = selectedModel;
}
}