use of javax.faces.FacesException in project oxCore by GluuFederation.
the class ExternalResourceHandler method resolveUrl.
@Override
public URL resolveUrl(String path) {
if (!useExternalResourceBase) {
return this.parent.resolveUrl(path);
}
// First try external resource folder
final File externalResource = new File(this.externalResourceBaseFolder, path);
if (externalResource.exists()) {
try {
// tryToUpdateCachedPageXML(path);
log.debug("Found overriden resource: " + path);
URL resource = externalResource.toURI().toURL();
return resource;
} catch (MalformedURLException ex) {
throw new FacesException(ex);
}
}
// Return default resource
return this.parent.resolveUrl(path);
}
use of javax.faces.FacesException in project oxCore by GluuFederation.
the class UIInputContainer method getDefaultValidator.
/**
* Get the default Bean Validation Validator to read the contraints for a property.
*/
private Validator getDefaultValidator(final FacesContext context) throws FacesException {
if (!beanValidationPresent) {
return null;
}
ValidatorFactory validatorFactory;
Object cachedObject = context.getExternalContext().getApplicationMap().get(BeanValidator.VALIDATOR_FACTORY_KEY);
if (cachedObject instanceof ValidatorFactory) {
validatorFactory = (ValidatorFactory) cachedObject;
} else {
try {
validatorFactory = Validation.buildDefaultValidatorFactory();
} catch (ValidationException e) {
throw new FacesException("Could not build a default Bean Validator factory", e);
}
context.getExternalContext().getApplicationMap().put(BeanValidator.VALIDATOR_FACTORY_KEY, validatorFactory);
}
return validatorFactory.getValidator();
}
use of javax.faces.FacesException in project deltaspike by apache.
the class ClientWindowHelper method handleInitialRedirect.
/**
* Handles the initial redirect for the LAZY mode, if no windowId is available in the current request URL.
*
* @param facesContext the {@link FacesContext}
* @param newWindowId the new windowId
*/
public static void handleInitialRedirect(FacesContext facesContext, String newWindowId) {
// store the new windowId as context attribute to prevent infinite loops
// #sendRedirect will append the windowId (from ClientWindow#getWindowId again) to the redirectUrl
facesContext.getAttributes().put(INITIAL_REDIRECT_WINDOW_ID, newWindowId);
ExternalContext externalContext = facesContext.getExternalContext();
String url = constructRequestUrl(externalContext);
// remember the initial redirect windowId till the next request - see #729
addRequestWindowIdCookie(facesContext, newWindowId, newWindowId);
try {
externalContext.redirect(url);
} catch (IOException e) {
throw new FacesException("Could not send initial redirect!", e);
}
}
use of javax.faces.FacesException in project deltaspike by apache.
the class ClientSideWindowStrategy method sendWindowHandlerHtml.
protected void sendWindowHandlerHtml(ExternalContext externalContext, String windowId) {
HttpServletResponse httpResponse = (HttpServletResponse) externalContext.getResponse();
try {
httpResponse.setStatus(HttpServletResponse.SC_OK);
httpResponse.setContentType("text/html");
String windowHandlerHtml = clientWindowConfig.getClientWindowHtml();
if (windowId == null) {
windowId = UNINITIALIZED_WINDOW_ID_VALUE;
}
// set the windowId value in the javascript code
windowHandlerHtml = windowHandlerHtml.replace(WINDOW_ID_REPLACE_PATTERN, windowId);
// set the current request url
// on the client we can't use window.location as the location
// could be a different when using forwards
windowHandlerHtml = windowHandlerHtml.replace(REQUEST_URL_REPLACE_PATTERN, ClientWindowHelper.constructRequestUrl(externalContext));
// set the noscript-URL for users with no JavaScript
windowHandlerHtml = windowHandlerHtml.replace(NOSCRIPT_URL_REPLACE_PATTERN, getNoscriptUrl(externalContext));
OutputStream os = httpResponse.getOutputStream();
try {
os.write(windowHandlerHtml.getBytes());
} finally {
os.close();
}
} catch (IOException ioe) {
throw new FacesException(ioe);
}
}
use of javax.faces.FacesException 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;
}
Aggregations