0

I have a problem. I use component treeTable, and I need dynamically update its. When I am using <p:poll> it updated fully, but I need update only value. I don't want, that after update treeTable size of column were reset to default, for example.

<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;
        }
    }
  • I think you should update the `` if you have several of them you can use comma `,` in update tag: `update="firstID, secondID"` – Behnam Safari Feb 20 '14 at 08:29
  • As I understood, it's element inside column? – user3331721 Feb 20 '14 at 08:40
  • did you see this: http://www.primefaces.org/showcase/ui/treeTable.jsf in this site in `` if it had an id, so updating it with it's id is possible. – Behnam Safari Feb 20 '14 at 08:42
  • writing your code here would help me to help you. – Behnam Safari Feb 20 '14 at 08:44
  • I suppose, that need save my state before update root, but I don't know, how I can do this. – user3331721 Feb 20 '14 at 09:11
  • If I'm trying use follow code then I'm getting - Cannot find component with expression "value" referenced from "form:j_idt55". – user3331721 Feb 20 '14 at 09:29
  • yes you are doing right, just you are addressing 'value' identifier badly, take a look here:http://stackoverflow.com/questions/18432751/cannot-find-component-with-identifier-hselectbooleancheckbox-outside-pdatatabl and here http://stackoverflow.com/questions/13499642/primefaces-cannot-find-component-with-identifier-outside-the-datatable – Behnam Safari Feb 20 '14 at 10:38
  • Thanks a lot for your help. Exception is disappeared, but my issue isn't solved, because treeTable isn't updated. – user3331721 Feb 20 '14 at 12:37

0 Answers0