我开发了一个用于统计的JEE / JSF接口。我创建了checkbox来选择用户希望显示的引用,但问题是我使用它来根据数据库中的数据生成checkbox Arraylist。
我不能按我想要的方式来定位它们。我希望在10个复选框之后,其他人直接生成到行等。
我有这样的结果

我希望我能做到

MTBFBEAN
private List<String> selectedReference = new ArrayList<String>();
private List<String> listReference = new ArrayList<String>();
private Boolean afficher = false; // Déclaration du bool pour le rendered de
// ma vue dans MTBF
@SuppressWarnings("deprecation")
public StatisticsBeanMTBF() {
this.beginDate = new Date(2001, 00, 01);
List<ProductConfModel> listtmp = this.moduleGlobal.getProductConfModels(2);
for (ProductConfModel pcm : listtmp) {
this.listReference.add(pcm.getReference());
}
}
public void mTBFByType() {
this.afficher = true;
this.listMTBF = new ArrayList<StatistiquesMTBF>();
List<StatistiquesMTBF> suspense = this.moduleGlobal.getMTBFByType(nbHeure, nbJour, NS, DAE, beginDate, endDate);
for (StatistiquesMTBF smtbf : suspense) {
for (String s : this.selectedReference) {
if (smtbf.getReference().equals(s)) {
this.listMTBF.add(smtbf);
}JSF XHTML
<h:outputText value="Date début :* " />
<p:calendar value="#{statisticsBeanMTBF.beginDate}"
navigator="true" required="true" />
<h:outputText value="Date fin:* " />
<p:calendar value="#{statisticsBeanMTBF.endDate}" navigator="true"
required="true" />
</h:panelGrid>
<h:panelGrid columns="1">
<h:outputText value="Selectionner votre référence : " />
<p:selectManyCheckbox id="grid" columns="5"
value="#{statisticsBeanMTBF.selectedReference}">
<f:selectItems value="#{statisticsBeanMTBF.listReference}" />
</p:selectManyCheckbox>
</h:panelGrid>
<p:separator />如果有人能帮我,那就太好了。
谢谢!
发布于 2013-11-26 18:19:42
我使用以下命令获得此结果:
<h:panelGroup layout="block" styleClass="selection">
<p:selectManyCheckbox layout="pageDirection" value="#{selection.selection}">
</h:panelGroup>并设置每个<tr>
.selection tr {
float: left;
width: 33%;
} 在您的示例中,将其设置为10%,并将外部容器设置为width: 100%。
看起来是这样的:

发布于 2013-11-26 18:14:33
您应该根据此example将layout="grid"添加到您的p:selectManyCheckbox中。如下所示:
<p:selectManyCheckbox id="grid" layout="grid" columns="5" value="#{statisticsBeanMTBF.selectedReference}">
<f:selectItems value="#{statisticsBeanMTBF.listReference}" />
</p:selectManyCheckbox>编辑:
对PrimeFaces文档的快速搜索显示,columns是在4.0版中添加的。如果你没有这个版本或者不能升级,你需要用一些CSS的老方法来做。
https://stackoverflow.com/questions/20213248
复制相似问题