在空 table 单元格中打印

Print   in empty table cell

我想创建具有可点击行的 JSF table。示例:

<h:column>
    <f:facet name="header">
        <h:commandLink value="User name" actionListener="#{bean.sort}" style="text-decoration:none;">
            <f:ajax render="@form" />
        </h:commandLink>
    </f:facet>
    <h:commandLink value="#{item.userName}" action="#{accounts.pageRedirect}" style="text-decoration:none;">
        <f:setPropertyActionListener target="#{accounts.sessionValue}" value="#{item.number}" />
    </h:commandLink>
</h:column>

但是当我有空单元格时,该行会缩小。我试过这个解决方案

 table { empty-cells: show; }

http://www.cs.tut.fi/~jkorpela/HTML/emptycells.html

但根据文章,它不适用于 IE。所以我需要使用 &nbsp;

如果值为空,我如何在 h:commandLink value="#{item.userName}" 中实现一些逻辑来打印 &nbsp;

P.S 我想我需要这样的东西:

value="#{item.number == null ? &nbsp; : item.number}"

您需要使用rendered属性来条件显示内容:

<h:column>
     <h:commandLink value="#{item.userName}" action="#{accounts.pageRedirect}" style="text-decoration:none;" rendered="#{item.number != null}">
          <f:setPropertyActionListener target="#{accounts.sessionValue}" value="#{item.number}" />
     </h:commandLink>

     <h:outputText value="&#160;" rendered="#{item.number == null}" />
</h:column>

另请参阅以下链接以了解我将 &nbsp; 替换为 &#160; 的原因:

  • How do I insert non breaking space character &nbsp; in a JSF page?
  • Error Parsing /page.xhtml: Error Traced[line: 42] The entity "nbsp" was referenced, but not declared