jsf - 渲染 p :selectManyCheckbox with 10 columns

标签 jsf primefaces multiple-columns selectmanycheckbox

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

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

我有这个结果

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

我希望我能做到这一点

enter image description here

MTBF bean

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

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

谢谢 !

最佳答案

我得到这个结果使用:

<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% .

看起来像这样:

enter image description here

关于jsf - 渲染 p :selectManyCheckbox with 10 columns,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20213248/

相关文章:

jsf - 在固定大小的表中设置 JSF 列标题的宽度

jsf - <c :when> not working in PrimeFaces datatable?

java - 区分插入和更新

javascript - 如何检查是否富有 :component returns null

css - Primefaces googlemap 不呈现

jsf - 如何延迟加载与 p :Tab, 中包含的页面关联的 ManagedBean 仅在打开 Tab 时

excel - 使用 SAS 处理 Excel 中的大量列

css - 两栏布局,内容优先

python - 在不使用 ".insert"/不手动重新排序的情况下添加列时,如何在数据表中的特定位置插入列?

java - JSF 中基于表单的身份验证