0

How can i update datatable in primefaces.Datatable updates only when i refresh the page. I have found some solutions but none of them worked for me.For example when i change update to ":companyForm:companyPanel" save button disappers. I removed colon and now i can see button but still doesn't update datatable. Here is my jsf page;

<h:form id="companyForm" prependId="false">
  <p:panel id="companyPanel">
    <p:dataTable id="companyListTable">
     //columns
    </p:dataTable>
  </p:panel>

<p:outputPanel id="newDatePanel">
  <p:commandButton value="Save"                                         
    update="companyForm:companyPanel
    companyForm:newDatePanel"                                         
    action="#{myController.save()}"/>
</p:outputPanel>
</form>

and my spring controller;

init(){
    companyList = service.getAllCompany();
}

public void save(){
    service.save(company);
}
4

1 回答 1

2

实际上你的 id 搞砸了,否则组件会被刷新。

组件的实际客户端 ID 取决于标签所在的命名容器。在这种情况下,命名容器是<h:form>. 当您prependId="false"在表单标签中包含属性时,嵌套的客户端 ID<p:panel id="companyPanel">将是companyPanel,否则(如果您prependId完全省略) - 它将是companyForm:companyPanel.

尽管如此,当您想在同一个命名容器(表单)中更新组件时,您不需要在它前面加上表单 id 并让它变得简单<p:commandButton update="companyPanel">:没有冒号和没有表单 id,有没有。

在您的代码现在的状态下,没有 id 的组件companyForm:companyPanel

于 2013-04-25T10:39:52.870 回答