
org.javabeanstack.web.util.FacesContextUtil Maven / Gradle / Ivy
/*
* JavaBeanStack FrameWork
*
* Copyright (C) 2018 Jorge Enciso
* Email: [email protected]
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.javabeanstack.web.util;
import java.util.Map;
import javax.faces.application.Application;
import javax.faces.application.FacesMessage;
import javax.faces.application.ViewHandler;
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.javabeanstack.security.IUserSession;
import org.primefaces.PrimeFaces;
public class FacesContextUtil {
public FacesContext getFacesContext() {
return FacesContext.getCurrentInstance();
}
public Application getApplication() {
return getFacesContext().getApplication();
}
public PrimeFaces getRequestContext() {
return PrimeFaces.current();
}
public ExternalContext getExternalContext(){
return getFacesContext().getExternalContext();
}
public String getRequestContextPath(){
return getExternalContext().getRequestContextPath();
}
public String getRealPath(String path){
return getExternalContext().getRealPath(path);
}
public UIViewRoot getUIViewRoot() {
ViewHandler viewHandler = getApplication().getViewHandler();
return viewHandler.createView(getFacesContext(), getFacesContext().getViewRoot().getViewId());
}
public HttpSession getSession(){
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest req = (HttpServletRequest)context.getExternalContext().getRequest();
HttpSession session = req.getSession();
return session;
}
public Map getSessionMap(){
return FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
}
public Map getRequestMap(){
return FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
}
public Map getRequestParameterMap(){
return FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
}
public Map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy