af converter does not work with managed bean attribute
If you have a UI component , for example output text ,binned managed bean attribute and you want to format the output of this attribute in a decimal format for example, then you have to do this within the managed bean it self.
Example:
so the solution is to format the value within the managed bean class , like this
public void setPaidAmountBase(String paidAmountBase) {
this.paidAmountBase = paidAmountBase;
}
public String getPaidAmountBase() {
DecimalFormat df = new DecimalFormat("##,###.000");
System.out.println(df.format(new BigDecimal(paidAmountBase==null?"0":paidAmountBase)));
return df.format(new BigDecimal(paidAmountBase==null?"0":paidAmountBase));
}
Example:
if you have an output text that its value is a managed bean attribute and you insert inside this output text a converter to convert the output to decimal format ,this will not work.
so the solution is to format the value within the managed bean class , like this
public void setPaidAmountBase(String paidAmountBase) {
this.paidAmountBase = paidAmountBase;
}
public String getPaidAmountBase() {
DecimalFormat df = new DecimalFormat("##,###.000");
System.out.println(df.format(new BigDecimal(paidAmountBase==null?"0":paidAmountBase)));
return df.format(new BigDecimal(paidAmountBase==null?"0":paidAmountBase));
}
Comments