10_hangman/src/AbstractHangmanElement.java

/*
 * Copyright 2001-2006 Geert Bevin <gbevin[remove] at uwyn dot com>
 * Distributed under the terms of either:
 * - the common development and distribution license (CDDL), v1.0; or
 * - the GNU Lesser General Public License, v2.1 or later
 * $Id: AbstractHangmanElement.java 3364 2006-07-10 10:33:29Z gbevin $
 */
import com.uwyn.rife.engine.Element;
import javax.servlet.http.HttpSession;
import model.Game;
import model.WordGenerator;

public abstract class AbstractHangmanElement extends Element {
    public Game getGame() {
        HttpSession session = getHttpServletRequest().getSession();
        Game game = (Game)session.getAttribute("game");
        if (null == game) {
            game = new Game();
            game.newGame(5, new WordGenerator());
            session.setAttribute("game", game);
        }
        return game;
    }
    
    public boolean prohibitRawAccess() {
        return false;
    }
}