Created
June 13, 2012 12:37
-
-
Save lezi/2923812 to your computer and use it in GitHub Desktop.
A JSF Converter model accessing an ejb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * | |
| * @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