Cannot use a custom converter when bound to a DataProvider
Hello everyone,
I have created a simple JSF page with Table bound to to a DataProvider that gets its data from a MySQL database. The cells in the Table are StaticTexts. I then wrote a custom converter that formats phone numbers (e.g. from 5555555555 to 555-555-5555). Here is the code for the converter:
package school;
import javax.faces.context.*;
import javax.faces.component.*;
publicclass PhoneConverterimplements javax.faces.convert.Converter{
public Object getAsObject(FacesContext context, UIComponent component, String value){
String retval ="";
retval = value.substring(1, 4) + retval.substring(5, 8) + retval.substring(9);
return retval;
}
public String getAsString(FacesContext context, UIComponent component, Object value){
String retval = (String) value;
retval ="(" + retval.substring(0, 3) +") " + retval.substring(3, 6) +"-" + retval.substring(6);
return retval;
}
}
I registered the custom converter in faces-config.xml as such:
<converter>
<converter-id>PhoneConverter</converter-id>
<converter-class>school.PhoneConverter</converter-class>
</converter>
I then used it on my JSP page as such:
<ui:tableColumn binding="#{EditStudents.tableColumn7}" headerText="CellPhone" id="tableColumn7" sort="students.CellPhone">
<ui:staticText binding="#{EditStudents.staticText7}" id="staticText7" text="#{currentRow.value[students.CellPhone']}" converter="PhoneConverter"/>
</ui:tableColumn>
When I run the page now, the converter is not applied. However, if I changed text so the number is hardcoded (e.g. 5555555555), then the converter works. How come the converter doesn't work when the StaticText is bound to a DataProvider? Am I forgetting to do something or is this a bug in Studio Creator? Thank you.
Peter

