AI. AI. - 26 days ago 13
MySQL Question

How to change MySQL value inside mybatis?

I have a supplier table with column

gst_invoice_type
. The table have two rows, with value F and S.

In my PrimeFaces dataTable, I also created a table with column
Gst_Invoice_Type
with drop down menu filter as below code

<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. But is it possible to let the F and S display as Full Tax Invoice and Simplified Invoice ?

Answer

Simply insert two conditionally rendered <h:outputText /> elements with different values.

<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>

Another option is to do the mapping programmatically in a bean method like:

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

with

public class Bean {
  public String map(String input) {
    // however you implement your mapping
  }
}
Comments