view src/main/java/de/mpiwg/web/AbstractBean.java @ 2:1f56cf4f80d4

Fix of bug in the creation of a new file.
author "jurzua <jurzua@mpiwg-berlin.mpg.de>"
date Wed, 11 Mar 2015 16:00:42 +0100
parents 7682c04c63a8
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();
	}
	
}