Skip to content

Instantly share code, notes, and snippets.

@lezi
Created June 13, 2012 12:37
Show Gist options
  • Select an option

  • Save lezi/2923812 to your computer and use it in GitHub Desktop.

Select an option

Save lezi/2923812 to your computer and use it in GitHub Desktop.
A JSF Converter model accessing an ejb
/**
*
* @author Mwanalezi
*/
@FacesConverter(value = "aeroportoConverter", forClass = Aeroporto.class)
public class AeroportoConverter implements Converter {
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
Long id = Long.valueOf(value);
System.out.println("Aqui: " + id);
Aeroporto aeroporto = new Aeroporto();
try {
InitialContext ic = new InitialContext();
IAeroporto servico =
(IAeroporto) ic.lookup("java:global/sigenana/sigenana-ejb/AeroportoFacade");
aeroporto = servico.getByCodigo(id);
} catch (NamingException e) {
e.printStackTrace();
}
return aeroporto;
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
return value.toString();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment