简体   繁体   中英

Conversion error {0} in Primefaces knob component

I get a error: Conversion error:

{0}: Conversion error occurred.

when try to display O value in Primefaces knob component. I already changed input value types to: integer, String, Double and this did not help. I also tried to build a converter, but this component did not use it. I donot have any ide what do with this. I have no idea how to solve this problem.

<p:knob value="#{res.completionValue}" width="50" height="50" disabled="true" converter="knobConverter" />

Converter:

@FacesConverter("knobConverter")
public class KnobConverter implements Converter {

    public Object getAsObject(FacesContext fc, UIComponent uic, String value) {
        
        Integer returnValue;
        
        if(value != null && value.trim().length() >0) {
             try{
                 returnValue = (ing) value;
                }
             catch(NumberFormatException e) {
                throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Conversion Error", "Not a valid theme."));
            }}
                
        return returnValue;
}
 
    public String getAsString(FacesContext fc, UIComponent uic, Object object) {
        
        if(object != null) {
            return String.valueOf((object));
        }
        else {
            return null;
        }
    }   
}

I deleted the entire class and recreated it (return Integer values, do no use Converter). Now it work correct, generally I do not have any idea what was the reason.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM