In the database the periods that is the same as the month is saved in numbers but I want to convert them to String so that the end user in the table can see the names of the months, the same case happens with the column made that only has 2 options 1 or 0 but I want to change with pending or done
Investigating I came across the FacesConverter entry and create a class as follows.
@FacesConverter(value = "periodoConverter")
public class PeriodoConverter implements Converter {
@Override
public Object getAsObject(FacesContext fc, UIComponent uic, String string) {
return string;
}
@Override
public String getAsString(FacesContext fc, UIComponent uic, Object value) {
int periodo = 1;
String periodo1 = "";
if (value != null) {
switch (periodo) {
case 1:
periodo1 = "Enero";
break;
case 2:
periodo1 = "Febrero";
break;
case 3:
periodo1 = "Marzo";
break;
case 4:
periodo1 = "Abril";
break;
case 5:
periodo1 = "Mayo";
break;
case 6:
periodo1 = "Junio";
break;
case 7:
periodo1 = "Julio";
break;
case 8:
periodo1 = "Agosto";
break;
case 9:
periodo1 = "Septiembre";
break;
case 10:
periodo1 = "Octubre";
break;
case 11:
periodo1 = "Noviembre";
break;
case 12:
periodo1 = "Diciembre";
break;
}
}
return periodo1;
}
}
and on the front:
<p:column headerText="Periodo" >
<h:outputLabel value="#{reg.periodoDatos}" >
<f:converter converterId="periodoConverter" />
</h:outputLabel>
</p:column>
but I do not know why it does not work and it appears blank, any help I would thank you from my heart a thousand thanks.