Search in sources :

Example 11 with ExternalContext

use of javax.faces.context.ExternalContext in project tomee by apache.

the class TomEEFacesConfigurationProviderFactory method getFacesConfigurationProvider.

@Override
public FacesConfigurationProvider getFacesConfigurationProvider(final ExternalContext externalContext) {
    FacesConfigurationProvider returnValue = (FacesConfigurationProvider) externalContext.getApplicationMap().get(FACES_CONFIGURATION_PROVIDER_INSTANCE_KEY);
    if (returnValue == null) {
        final ExternalContext extContext = externalContext;
        try {
            returnValue = resolveFacesConfigurationProviderFromService(extContext);
            externalContext.getApplicationMap().put(FACES_CONFIGURATION_PROVIDER_INSTANCE_KEY, returnValue);
        } catch (final ClassNotFoundException | NoClassDefFoundError e) {
        // ignore
        } catch (final InstantiationException | InvocationTargetException | IllegalAccessException e) {
            getLogger().log(Level.SEVERE, "", e);
        } catch (final PrivilegedActionException e) {
            throw new FacesException(e);
        }
    }
    return returnValue;
}
Also used : PrivilegedActionException(java.security.PrivilegedActionException) ExternalContext(javax.faces.context.ExternalContext) FacesConfigurationProvider(org.apache.myfaces.spi.FacesConfigurationProvider) InvocationTargetException(java.lang.reflect.InvocationTargetException) FacesException(javax.faces.FacesException)

Example 12 with ExternalContext

use of javax.faces.context.ExternalContext in project chuidiang-ejemplos by chuidiang.

the class UserLogin method validate.

public String validate() {
    if ("juan".equals(userName) && "pedro".equals(password)) {
        HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
        session.setAttribute("userName", userName);
        ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
        try {
            context.redirect(context.getRequestContextPath() + "view.xhtml");
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return "view";
    } else {
        return "login";
    }
}
Also used : HttpSession(javax.servlet.http.HttpSession) ExternalContext(javax.faces.context.ExternalContext) IOException(java.io.IOException)

Aggregations

ExternalContext (javax.faces.context.ExternalContext)12 FacesContext (javax.faces.context.FacesContext)5 IOException (java.io.IOException)2 FacesException (javax.faces.FacesException)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 LdapMappingException (org.gluu.site.ldap.persistence.exception.LdapMappingException)2 ScopeDescription (org.xdi.oxauth.model.uma.persistence.ScopeDescription)2 ContentDisposition (org.xdi.util.io.FileDownloader.ContentDisposition)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 PrivilegedActionException (java.security.PrivilegedActionException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 ConfigurableNavigationHandler (javax.faces.application.ConfigurableNavigationHandler)1 ExceptionQueuedEvent (javax.faces.event.ExceptionQueuedEvent)1 ExceptionQueuedEventContext (javax.faces.event.ExceptionQueuedEventContext)1 HttpSession (javax.servlet.http.HttpSession)1 NavigationParameterContext (org.apache.deltaspike.core.api.config.view.navigation.NavigationParameterContext)1