我从 SO How to use <h:selectBooleanCheckbox> in <h:dataTable> 中解决了这个问题来选择多行?
使用上面问题中所示的单个复选框,我想知道我是否可以使 h:datatable 单元格可编辑,以便用户可以一次编辑所有行和列并提交
这是bean类的一部分
public class bean {
private List<Group> GroupList;
private Map<Long, Boolean> checked = new HashMap<Long, Boolean>();
public void setChecked(Map<Long, Boolean> checked) {
this.checked = checked;
}
public Map<Long, Boolean> getChecked() {
return checked;
}
}
这是我的 JSF 页面
<h:dataTable id="editTable" styleClass = "listtable" value="#{bean.GroupList}" var="group" border="1" first="0" rows="8" width="75%" frame="hsides" rules="all" cellpadding="5" headerClass="tableheading" rowClasses="firstrow, secondrow">
<f:facet name="header">
<h:outputText value="Groups"></h:outputText>
</f:facet>
<h:column>
<f:facet name="header">
<h:outputText value="GroupId"></h:outputText>
</f:facet>
<h:outputText value="#{group.Id}" rendered=""></h:outputText>
<h:inputText value="#{group.Id}" rendered=""/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="GroupName"></h:outputText>
</f:facet>
<h:outputText value="#{group.Name}" rendered=""></h:outputText>
<h:inputText value="#{group.Name}" rendered=""/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Check to Enable/Disable"></h:outputText>
</f:facet>
<h:selectBooleanCheckbox value="#{bean.checked[group.Id]}" />
</h:column>
</h:dataTable>
应该在渲染属性中保留什么,以便在检查时呈现 h:inputtext 而在未选中时呈现 h:outputtext?