Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- }
- }
- javax.persistence.Converter
- javax.faces.convert.Converter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement