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;
}
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";
}
}
Aggregations