Java examples for JSF:FacesContext
Remove a JSF Bean from the application map.
/**//from w w w. j a v a2 s . co m * License: src/main/resources/license/escidoc.license */ import javax.faces.application.FacesMessage; import javax.faces.application.FacesMessage.Severity; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import org.apache.log4j.Logger; public class Main{ public static void main(String[] argv) throws Exception{ Class cls = String.class; removeBeanFromMap(cls); } /** * Remove a Bean from the application map. Can be used to force a bean to be reinitialized * * @param cls */ public static synchronized void removeBeanFromMap(final Class<?> cls) { String name = cls.getSimpleName(); Object result = FacesContext.getCurrentInstance() .getExternalContext().getApplicationMap().get(name); if (result != null) FacesContext.getCurrentInstance().getExternalContext() .getApplicationMap().remove(name); } }