All pastes #2126400 Raw Edit

ViewScoped not working

public java v1 · immutable
#2126400 ·published 2012-03-09 14:30 UTC
rendered paste body
/* Relevat imports: */import java.io.Serializable;import java.util.List;import javax.annotation.PostConstruct;import javax.ejb.EJB;import javax.ejb.PrePassivate;import javax.ejb.Stateful;import javax.faces.application.FacesMessage;import javax.faces.bean.ViewScoped;import javax.faces.context.FacesContext;import javax.inject.Named;/* relevant excerpt of the class */@Stateful@ViewScoped@Named("insightEdit")public class InsightEditBean implements Serializable {	/* .... */	public InsightEditBean() {	}	@PostConstruct	public void initialize() {		Long id = null;		System.out.println("Initializing InsightEditBean...");		try {			id = Long.parseLong(FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("id"));			try {				insight = pool.getInsight(id);				mode = Mode.EDIT;				System.out.println("Category of this insight: " + insight.getCategory().getName());			} catch (final Exception e) {				final FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,						"Could not load insight from database (probably ID=" + id +" is invalid): "+ e.getMessage(),						null);				FacesContext.getCurrentInstance().addMessage(null, message);				id = null;				mode = Mode.ADD;				// TODO: Implement error page when incorrect ID was specified (instead of forwarding to an add insight page)			}		} catch (final Exception e) {			mode = Mode.ADD;		}		if(mode == Mode.ADD) {			insight = new Insight();		}		System.out.println("Conversation started");	}	@PrePassivate	public void destroy() {		System.out.println("PrePassivate");	}/* ... */}