1

我有一个带有列的供应商表gst_invoice_type。该表有两行,值为 F 和 S。

在我的 PrimeFaces 数据表中,我还创建了一个Gst_Invoice_Type带有下拉菜单过滤器列的表,如下代码所示

<p:column filterBy="#{vo.gstInvoiceType}" headerText="GST Invoice Type." sortBy="#{vo.gstInvoiceType}"
                        style="width:130px;" visible="false">
                    <f:facet name="filter">
                        <p:selectOneMenu style="width:110px; vertical-align:middle;" autoWidth="false"
                        onchange="PF('varTable').filter()">
                            <f:selectItem itemLabel="ALL" itemValue="" noSelectionOption="true" />
                            <f:selectItem itemLabel="Full Tax Invoice" itemValue="F" />
                            <f:selectItem itemLabel="Simplified Invoice" itemValue="S" />
                        </p:selectOneMenu>
                    </f:facet>
                    <h:outputText value="#{vo.gstInvoiceType}"/>
                </p:column>

When select All, all data (F and S) will be retrieved and located in Gst_Invoice_Type, which working correctly. 但是是否可以让 F 和 S 显示为 Full Tax Invoice 和 Simplified Invoice ?

4

1 回答 1

3

只需插入两个<h:outputText />具有不同值的条件渲染元素。

<p:column>
  <h:outputText
    value="Full Tax Invoice"
    rendered="#{vo.gstInvoiceType eq 'F'}"
  />
  <h:outputText
    value="Simplified Invoice"
    rendered="#{vo.gstInvoiceType eq 'S'}"
  />
</p:column>

另一种选择是在 bean 方法中以编程方式进行映射,例如:

<p:column>
  <h:outputText value="#{bean.map(vo.gstInvoiceType)}" />
</p:column>

public class Bean {
  public String map(String input) {
    // however you implement your mapping
  }
}
于 2016-11-09T07:00:08.207 回答