Package Controle

Source Code of Controle.UnidadeConverter

package Controle;

import DAO.UnidadeDao;
import Entidade.Unidade;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

@FacesConverter(forClass = Unidade.class, value = "unidadeConverter")
public class UnidadeConverter implements Converter{
    
    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        if (value != null && !"".equals(value)) {
            //return new UnidadeDao().consultarPorId(Integer.parseInt(value));
            Unidade unidade = new UnidadeDao().consultarPorId(Integer.parseInt(value));

           
            if (unidade != null){
               return unidade;
            }
        }
        return null;
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        if (value != null  ) {
            return value.toString();
        }
        return null;
    }


}
TOP

Related Classes of Controle.UnidadeConverter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.