// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
package test;

import java.util.Map;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ComponentSystemEvent;

@ManagedBean
@RequestScoped
public class TestBean {
    public void check(ComponentSystemEvent event){
        Map<String, Object> session = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
        if(!session.containsKey("V")) {
            session.put("V", 1);
        } else {
            session.put("V", (Integer)session.get("V") + 1);
        }
        Map<String, Object> application = FacesContext.getCurrentInstance().getExternalContext().getApplicationMap();
        if(!application.containsKey("V")) {
            application.put("V", 1);
        } else {
            application.put("V", (Integer)application.get("V") + 1);
        }
    }
}
