【发布时间】:2014-01-02 13:45:27
【问题描述】:
我使用<rich:datatable> 来显示来自List<Map<String, String>> 的数据(实际上,该列表只有一个Map<String, String>)。 datatable 在一行中显示数据,并在行旁边显示一个编辑和删除按钮。
当我单击delete button 时,我会从List 和数据库中清除注册表。我想,当我单击delete button 时,不要显示来自datatable 的内容并禁用edit 和delete buttons。这是数据表代码:
<rich:dataTable value="#{searchAuthDetailController.finalResults}"
id="table" var="result">
<c:forEach items="#{searchAuthDetailController.variableNames}" var="vname">
<rich:column>
<f:facet name="header">#{vname}</f:facet>
#{result[vname]}
</rich:column>
</c:forEach>
<rich:column>
<h:commandButton action="EditAuthor" value="Edit"
disabled="#{searchAuthDetailController.editBtDisabled}">
<f:setPropertyActionListener target="#{editAuthController.selectedAuthor}"
value="#{searchAuthDetailController.selectedAuthor}"/>
</h:commandButton>
</rich:column>
<rich:column>
<a4j:commandButton value="Delete" disabled="#{searchAuthDetailController.deleteBtDisabled}"
action="#{searchAuthDetailController.removeSelectedAuthor()}" render="table"/>
</rich:column>
</rich:dataTable>
还有一个List<String> 在datatable 下方显示一些链接。在我点击删除按钮后,我希望这些链接和上面的文字不再出现。
<h:outputText value="#{searchAuthDetailController.linksLabel}" />
<br />
<a4j:repeat value="#{searchAuthDetailController.sameasListToShow}" var="uri" >
<a href="#{uri}">#{uri}</a>
<br />
</a4j:repeat>
我使用 2 个变量,称为 deleteBtDisabled 和 editBtDisabled 作为按钮中 disabled property 的值。在 remove()(下面的代码)处,我将这些变量设置为 true,并清除 List<Map<String, String>>、变量名 List、List 显示的链接和 linkslabel。
这里是remove():
public void removeSelectedAuthor() {
this.authMapper.remove(bdModel, this.selectedAuthor);
this.variableNames.clear();
this.editBtDisabled = true;
this.deleteBtDisabled = true;
this.sameasListToShow.clear();
this.linksLabel = "";
}
另外,delete button 的render 属性设置为datatable's id。
使用所有这些代码,当我单击删除按钮时,只有数据表中的内容消失,但按钮继续启用,链接列表继续存在。
我该如何解决这个问题?
【问题讨论】: