如何在数据表的命令链接中使用 ajax 禁用表单字段

How to disable a form field using ajax in a commandlink of a datatable

本文关键字:ajax 字段 表单 链接 数据表 命令      更新时间:2023-09-26

我上面有一个表单,用于捕获合同记录并将它们显示在具有命令链接"编辑"标签的数据表中。当我单击"编辑"时,我希望表单填充此合同数据,但禁用合同编号字段。我正在尝试在 Ajax onEvent 标签中执行此操作禁用并且它正在工作(即禁用)。但是,在使用 ajax 时,字段不会在表单中填充/显示。如果我删除它,一切都很好,只有合同号将可编辑。这些是我的编辑标签。

<h:commandLink id="editLink"  value="#{bundle.ListUnitEditLink}"   >
   <f:ajax   onevent="disablePK" listener="#{contractManager.updateContract}"  />
</h:commandLink>

这是我的背豆。

public String updateContract() {
    System.out.println("Now in UPDATECONTRACT method and serious debugging");
    current = (Contract) items.getRowData();
    this.newContractId=current.getContractid();
    this.newContractDesc=current.getContractdesc();
    this.newContractDt=current.getContractdt();
    this.newContractAmt=current.getContractamt();
    this.newContractStrtDt=current.getContractstrtdt();
    this.newExpDuration=current.getExpduration();
    this.newCtdBy=current.getCtdby();
    this.newCtdOn=current.getCtdon();
    this.lstUpdBy=current.getLstupdby();
    this.lstUpdOn=current.getLstupdon();
    return "contracts";
}

Bean 中的属性被赋予了正确的值,但它们没有出现在要编辑的表单中。

我通过在 ajax 标签中添加 render=@all 解决了我的问题

 <h:commandLink id="editLink"  value="#{bundle.ListUnitEditLink}"  
                                       actionListener="#{contractManager.updateContract}">
         <f:ajax   onevent="disablePK"   render="@all"  />
 </h:commandLink>