Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. package com.mycompany.conversor;
  2.  
  3. import com.mycompany.entidades.agendaTipo;
  4. import com.mycompany.repositorio.agendaTipoRepositorio;
  5. import java.lang.annotation.Annotation;
  6. import javax.faces.component.UIComponent;
  7. import javax.faces.context.FacesContext;
  8. import javax.faces.convert.FacesConverter;
  9. import javax.inject.Inject;
  10. import javax.persistence.Converter;
  11.  
  12.  
  13. @FacesConverter(forClass = agendaTipo.class)
  14. public class agendaTipoConverter implements Converter{
  15.  
  16. @Inject
  17. private agendaTipoRepositorio agendaTipoRepositorio;
  18.  
  19. @Override
  20. public Object getAsObject(FacesContext context,
  21. UIComponent component, String value) {
  22. agendaTipo retorno = null;
  23. if (value != null && !"".equals(value)) {
  24. retorno = this.agendaTipoRepositorio.porId(new Long(value));
  25. }
  26. return retorno;
  27. }
  28.  
  29. @Override
  30. public String getAsString(FacesContext context,
  31. UIComponent component, Object value) {
  32. if (value != null) {
  33. agendaTipo agendaTipo = ((agendaTipo) value);
  34. return agendaTipo.getId() == null ? null : agendaTipo.getId().toString();
  35. }
  36. return null;
  37. }
  38. }
  39.  
  40. javax.persistence.Converter
  41.  
  42. javax.faces.convert.Converter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement