【问题标题】:how to remove worthless tags from jsf f:selectItem如何从 jsf f:selectItem 中删除无价值的标签
【发布时间】:2013-11-27 16:58:26
【问题描述】:

我将创建一个带有复选框的列表。 gmail邮箱之类的东西。我在 HTML table 标签中使用 h:selectManyCheckboxf:selectItem 。但是jsf标签,它自己会创建一个表并破坏我的表单。 id 如何对不再创建 input 标签的 jsf 标签说?
以下是我的代码的和平:

<tbody>
    <h:selectManyCheckbox value="#{MemberControl.selectedUser}">
    <c:forEach items="#{MemberSearchControl.members}" var="member" varStatus="status">
    <tr>
        <td><f:selectItem itemValue="#{member.id}"></f:selectItem> </td>
        <td><span>#{member.lastName}</span></td>
        <td><span>#{member.firstName}</span></td>
        <td><span>#{member.shareCount}</span></td>
        <td><span>#{member.phone}</span></td>
    </tr>
    </c:forEach>
    </h:selectManyCheckbox>  
</tbody>  

在下面你可以看到结果:

您有任何解决方案将复选框移动到正确的位置吗? (我使用纯 jsf 而不是 primefaces 或更多) 谢谢。

【问题讨论】:

    标签: jsf jsf-2


    【解决方案1】:

    此行为与documented 相同。您尝试解决此问题绝对没有意义。 &lt;c:forEach&gt;&lt;f:selectItem&gt; 应该只是 &lt;f:selectItems&gt; 并且您应该使用自定义渲染器来完成这项工作。 Tomahawk 之前已经为您做过,它的&lt;t:selectManyCheckbox&gt;layout="spread" 属性集,以及在所需位置声明的&lt;t:checkbox&gt; 组件,允许您完全控制标记:

    <!-- This piece renders _nothing_. -->
    <t:selectManyCheckbox id="foo" value="#{bean.selectedItems}" layout="spread">
        <f:selectItems value="#{bean.availableItems}" />
    </t:selectManyCheckbox>
    
    <!-- You can markup those the way you want. They solely render <input>. -->
    <t:checkbox for="foo" index="0" />
    <t:checkbox for="foo" index="1" />
    <t:checkbox for="foo" index="2" />
    <t:checkbox for="foo" index="3" />
    ...
    

    另一种方法是只修复您的 CSS 样式。看起来太像您过度概括了tabletrtd 等样式以应用于这些元素的所有,而不是仅由特定样式类(例如@987654332)应用的样式@ 代表&lt;h:dataTable styleClass="datatable"&gt;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-27
      • 2016-08-12
      相关资源
      最近更新 更多