view src/main/java/de/mpiwg/web/AbstractBean.java @ 5:5316e79f9a27

Implementation of search pagination and lazy loading to display the result set of a search.
author "jurzua <jurzua@mpiwg-berlin.mpg.de>"
date Mon, 16 Mar 2015 11:25:36 +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();
	}
	
}