0

我使用 JSF 2.0 创建了 Web 应用程序,其中有复选框可以选择为h:selectManyCheckbox. 下面是我的代码

<h:selectManyCheckbox value="#{UserRegistration.pagesSelected}" id="myPages">
    <f:selectItem itemValue="registerForPatentss" itemLabel="Register New Applicant"/>
    <f:selectItem itemValue="success" itemLabel="Register New Project" />
    <f:selectItem itemValue="getReportss" itemLabel="Patent Reports" />
    <f:selectItem itemValue="searhPatentss" itemLabel="Search For Project" />
    <f:selectItem itemValue="addUserss" itemLabel="Add User Account" />
    <f:selectItem itemValue="logPatentSystemss" itemLabel="System Log" />
    <f:selectItem itemValue="userlistss" itemLabel="Details Of Registered Users" />
</h:selectManyCheckbox>    

我得到的输出是

[] Register New Applicant [] Register New Project [] Patent Reports [] Search For Project [] Add User Account [] System Log [] Details Of Registered Users

问题是这是在一条线上

我想要的是如下。

[] Register New Applicant [] Register New Project [] Patent Reports [] Search For Project
[] Add User Account [] System Log [] Details Of Registered Users

一行4个复选框....

知道如何完成这项工作吗?

编辑 1

HTML 生成的输出是

<table id="myPages">
    <tr>
<td>
<input name="myPages" id="myPages:0" value="registerForPatentss" type="checkbox" checked="checked" /><label for="myPages:0" class=""> Register New Applicant</label></td>
<td>
<input name="myPages" id="myPages:1" value="success" type="checkbox" checked="checked" /><label for="myPages:1" class=""> Register New Project</label></td>
<td>
<input name="myPages" id="myPages:2" value="getReportss" type="checkbox" checked="checked" /><label for="myPages:2" class=""> Patent Reports</label></td>
<td>
<input name="myPages" id="myPages:3" value="searhPatentss" type="checkbox" checked="checked" /><label for="myPages:3" class=""> Search For Project</label></td>
<td>
<input name="myPages" id="myPages:4" value="addUserss" type="checkbox" checked="checked" /><label for="myPages:4" class=""> Add User Account</label></td>
<td>
<input name="myPages" id="myPages:5" value="logPatentSystemss" type="checkbox" checked="checked" /><label for="myPages:5" class=""> System Log</label></td>
<td>
<input name="myPages" id="myPages:6" value="userlistss" type="checkbox" /><label for="myPages:6" class=""> Details Of Registered Users</label></td>
    </tr>
</table>
4

3 回答 3

1

<t:selectManyCheckbox>用简单的用法描述查看 tomahawk's ,例如这里

于 2012-10-05T19:51:49.587 回答
1

你可以用 CSS 做到这一点:

    <style type="text/css">
        .cb table {
            width: 100%;
        }

        .cb tr {
            display: inline;
        }

        .cb td {
            display: inline-block;
            width: 24%;
        }
    </style>

    <h:form>
        <div class="cb">
            <h:selectManyCheckbox value="#{UserRegistration.pagesSelected}" id="myPages">
                <f:selectItem itemValue="registerForPatentss" itemLabel="Register New Applicant"/>
                <f:selectItem itemValue="success" itemLabel="Register New Project"/>
                <f:selectItem itemValue="getReportss" itemLabel="Patent Reports"/>
                <f:selectItem itemValue="searhPatentss" itemLabel="Search For Project"/>
                <f:selectItem itemValue="addUserss" itemLabel="Add User Account"/>
                <f:selectItem itemValue="logPatentSystemss" itemLabel="System Log"/>
                <f:selectItem itemValue="userlistss" itemLabel="Details Of Registered Users"/>
            </h:selectManyCheckbox>
        </div>
    </h:form>
于 2013-10-07T15:20:55.237 回答
0

使用战斧的库

xmlns:t="http://myfaces.apache.org/tomahawk"

<t:selectManyCheckbox value="#{UserRegistration.pagesSelected}" id="myPages" layout="pageDirection"  layoutWidth="4">
    <f:selectItem itemValue="registerForPatentss" itemLabel="Register New Applicant"/>
    <f:selectItem itemValue="success" itemLabel="Register New Project" />
    <f:selectItem itemValue="getReportss" itemLabel="Project Reports" />
    <f:selectItem itemValue="searhPatentss" itemLabel="Search For Project" />
    <f:selectItem itemValue="addUserss" itemLabel="Add User Account" />
    <f:selectItem itemValue="logPatentSystemss" itemLabel="System Log" />
    <f:selectItem itemValue="userlistss" itemLabel="Details Of Registered Users" />
</t:selectManyCheckbox>

参考

于 2012-10-05T19:59:37.927 回答