view src/main/java/de/mpiwg/web/AbstractBean.java @ 10:5610250d021a default tip

SectionsIndex, we added a method to print the setting of the VM
author "jurzua <jurzua@mpiwg-berlin.mpg.de>"
date Thu, 19 Mar 2015 11:46:33 +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();
	}
	
}