Package com.reobotenet.converter

Source Code of com.reobotenet.converter.LancamentosConverter

package com.reobotenet.converter;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

import com.reobotenet.model.Lancamento;
import com.reobotenet.repository.Lancamentos;
import com.reobotenet.util.CDILocator;

@FacesConverter(forClass = Lancamento.class)
public class LancamentosConverter implements Converter {

  private Lancamentos lancamentos;

  public LancamentosConverter() {
    this.lancamentos = CDILocator.getBean(Lancamentos.class);
  }

  @Override
  public Object getAsObject(FacesContext context,
      UIComponent component,
      String value) {

    Lancamento retorno = null;

    if (value != null) {
      retorno = this.lancamentos.porId(new Long(value));
    }
    return retorno;
  }

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

}
TOP

Related Classes of com.reobotenet.converter.LancamentosConverter

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.