Package com.mycompany.controllers

Source Code of com.mycompany.controllers.MovimientoConverter

package com.mycompany.controllers;

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

import com.mycompany.model.Movimiento;
import com.mycompany.repository.MovimientoRepository;

@FacesConverter(forClass = Movimiento.class)
public class MovimientoConverter implements
  Converter{

 
  private MovimientoRepository repository;

  public MovimientoConverter(){
     this.repository =
         CDILocator.
         getBean(MovimientoRepository.class);
  }
 
  @Override
  public Object getAsObject(FacesContext context, UIComponent component,
      String value) {
    Movimiento retorno = null;
    if (value!=null){
      retorno = this.repository.porId(new Long(value));
    }
    return retorno;
  }

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

Related Classes of com.mycompany.controllers.MovimientoConverter

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.