11

我为一些统计数据开发了一个接口 JEE / JSF。我创建了复选框来选择用户希望显示的引用,但问题是我用来根据数据库中的数据生成复选框 Arraylist。

而且我无法根据需要定位它们。我希望在 10 个复选框之后,其他人直接生成到行等。..

我有这个结果

http://image.noelshack.com/fichiers/2013/48/1385458240-after.jpg

我希望我能做到这一点

在此处输入图像描述

MTBF豆

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 />

如果有人可以帮助我,那就太好了。

谢谢 !

4

2 回答 2

14

我得到这个结果使用:

<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-26T10:19:41.837 回答
5

你应该根据这个例子添加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 以旧方式进行。

于 2013-11-26T10:14:32.817 回答