I'm trying to develop a hangman game.
Mainly I have an xhtml file which calls a jugadorController.preparePartida();
the code is:
public String preparePartida() {
try {
Map<String, Object> sesionMap = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
Integer id = (Integer) sesionMap.get("id_jugador");
Jugador jugador = getFacade().find(id);
Partida p = new Partida();
p.setIdJugador(jugador);
PartidaController partida = new PartidaController();
return partida.createPartida(p);
} catch (Exception e) {
JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
return null;
}
partida.CreatePartida code is:
public String createPartida(Partida partida) {
try {
current=partida;
ejbFacade.create(current);
JsfUtil.addSuccessMessage(ResourceBundle.getBundle("/Bundle").getString("PartidaCreated"));
return "jugar";
} catch (Exception e) {
JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
return null;
}
}
The problem is when create(current) is invoked. It doesn't work because ejbFacade is null.
How should I declare the classes correctly for this to run? Am I not calling some method?
Thank you!!!
PS. A desesperate computer science student who has no idea about Java... =)