如何有条件地更改输出文本
我有一个供应商表,列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>
如果选择全部,所有的数据(F和S)将被检索并位于正确工作的Gst_Invoice_Type中。但是是否可以让F和S显示为全额税务发票和简化发票?
只需插入两个有条件呈现的<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
}
}
谢谢,但如果我有100行的情况,并且一些列包含空白,您的答案是否会起作用? –
@AI。当然它会起作用(更加努力地写下不同情况下的代码)。 – irieill
谢谢,它的工作原理 –
对不起,我不明白这一点。请详细解释你想要什么或问题是什么。 – irieill
@irieill好的。我在MySQL中有'F'和'S'的值。有没有办法让F显示为Full Tax Invoice和S显示为PrimeFaces数据表中的简化发票? –