【发布时间】:2017-11-28 06:55:42
【问题描述】:
我有两种类型的复选框,一种是用于数据表标题中的 selectAll 复选框,另一种类型是为每一行选择复选框。
我正在做一个操作,所以我需要显示确认消息,如何从托管 Bean 中获取选中复选框的计数。
我的代码是用 JSF 1.2 编写的。
我可以选择所有记录,选择记录,ManagedBean 工作正常,但我需要知道其中有多少被选中删除。 这是JSF代码,
<i:commandLink id="delete"
onclick="if (!confirm('#{managedBean.deleteSelectedCount}')) return false;"
action="#{managedBean.deleteRecords}"
title="Delete records"
immediate="true">
<i:graphicImage url="images/icons/delete.gif" alt="Delete records" />
</i:commandLink>
;
;//Some coding
;
//Data table code starts
<i:dataTable id="caseDataTable"
<h:column>
<f:facet name="header">
<i:selectBooleanCheckbox id="selectAllRecords" title="select All records"
value="#{managedBean.selectAll}">
<a4j:support event="onclick" reRender="caseDataTable,globalMessages" action="#{managedBean.actionSelectAllRecordss}" onsubmit="showBusyIndicator();" oncomplete="hideBusyIndicator();" />
</i:selectBooleanCheckbox>
</f:facet>
<h:outputLabel for="selectCheckbox" value="selectCheckbox"/>
<i:selectBooleanCheckbox id="selectCheckbox"
title="select a record" value="#{managedBean.selected}" >
<a4j:support event="onclick" reRender="selectAllRecords, globalMessages" action="#{managedBean.actionSelectionChange}"
onsubmit="showBusyIndicator();" oncomplete="hideBusyIndicator();"/>
</i:selectBooleanCheckbox>
</h:column>
【问题讨论】:
-
托管 bean 的“范围”是什么?
-
再想一想...我认为最适合您的是发布minimal reproducible example 否则您可能最终得不到好的答案(因为它是 JSF 1.2)
-
托管 bean 范围是会话。
-
好的。也请发minimal reproducible example。
-
请在有问题的正文中发布代码,而不是在 cmets 中。从 cmets 读取代码很难。