我有一个列gst_invoice_type
的供应商表。该表有两行,值为F和S.
在我的PrimeFaces dataTable中,我还创建了一个包含列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>
当选择All时,将检索所有数据(F和S)并将其定位在Gst_Invoice_Type中,该Gst_Invoice_Type正常工作。但是可以让F和S显示为全额发票和简化发票吗?
答案 0 :(得分:1)
简单插入两个带有不同值的有条件渲染的<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
}
}