view src/main/java/de/mpiwg/web/AbstractBean.java @ 0:7682c04c63a8

First commit of the source code!
author "jurzua <jurzua@mpiwg-berlin.mpg.de>"
date Tue, 10 Mar 2015 14:50:41 +0100
parents
children
line wrap: on
line source

package de.mpiwg.web;

import java.util.ArrayList;

import javax.faces.context.FacesContext;

public class AbstractBean {

	public Object getRequestBean(String name){
		return FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get(name);
	}
	
	public SessionBean getSessionBean(){
		return (SessionBean)FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get(SessionBean.BEAN_NAME);
	}
	
	public void addMsg(String msg){
		if(getSessionBean().getMsgList() == null){
			getSessionBean().setMsgList(new ArrayList<String>());
		}
		if(!getSessionBean().getMsgList().contains(msg)){
			getSessionBean().getMsgList().add(msg);	
		}
	}
	
	public void listenerCloseMsgPopup(){
		System.out.println("listenerCloseMsgPopup");
		getSessionBean().setMsgList(null);
	}
	
	public void internalError(Exception e){
		addMsg("Internal Error: " + e.getMessage());
		e.printStackTrace();
	}
	
}