Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.ufop.financeiro.converter;
- import javax.faces.component.UIComponent;
- import javax.faces.context.FacesContext;
- import javax.faces.convert.Converter;
- import javax.faces.convert.FacesConverter;
- import javax.inject.Inject;
- import com.ufop.financeiro.model.Pessoa;
- import com.ufop.financeiro.repository.PessoasRepository;
- @FacesConverter(forClass = Pessoa.class)
- public class PessoasConverter implements Converter {
- @Inject //funciona graças ao OmniFaces
- private PessoasRepository pessoas;
- @Override
- public Object getAsObject(FacesContext context,
- UIComponent component, String value) {
- Pessoa retorno = null;
- if (value != null) {
- retorno = this.pessoas.searchById(new Long(value)); /* THIS.PESSOAS == NULL */
- }
- return retorno;
- }
- @Override
- public String getAsString(FacesContext context,
- UIComponent component, Object value) {
- if(value != null) return ((Pessoa) value).getId().toString();
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement