Method does not Override or implement a method from a supertype

Asked

Viewed 507 times

2

I’m creating a converter and it’s giving me this mistake:

Method does not Override or implement a method from a supertype

Converter code:

package com.mycompany.conversor;

import com.mycompany.entidades.agendaTipo;
import com.mycompany.repositorio.agendaTipoRepositorio;
import java.lang.annotation.Annotation;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.FacesConverter;
import javax.inject.Inject;
import javax.persistence.Converter;


@FacesConverter(forClass = agendaTipo.class)
public class agendaTipoConverter implements Converter{

    @Inject
    private agendaTipoRepositorio agendaTipoRepositorio;

    @Override
    public Object getAsObject(FacesContext context,
    UIComponent component, String value) {
        agendaTipo retorno = null;
        if (value != null && !"".equals(value)) {
            retorno = this.agendaTipoRepositorio.porId(new Long(value));
        }
        return retorno;
    }

    @Override
    public String getAsString(FacesContext context,
    UIComponent component, Object value) {
        if (value != null) {
            agendaTipo agendaTipo = ((agendaTipo) value);
            return agendaTipo.getId() == null ? null : agendaTipo.getId().toString();
        }
        return null;
    }
}
  • Post the full stacktrace and other, do your classes start with lowercase letter? That’s out of the pattern but it’s another story.

  • Douglas the error is giving in netbeans still, because when I started with Java was so minuscula first letter second upper but anyway. Error gives inside netbeans

1 answer

0

You are importing the wrong "Convert" class. The import you used was this:

javax.persistence.Converter

Change the import to this:

javax.faces.convert.Converter

The Converter you used is part of the JPA implementation, which has nothing to do with JSF converters, and because the methods to implement them are different classes are obviously also different.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.