use of com.sun.faces.config.WebConfiguration in project mojarra by eclipse-ee4j.
the class FacesContextFactoryImpl method getFacesContext.
// ---------------------------------------- Methods from FacesContextFactory
@Override
public FacesContext getFacesContext(Object sc, Object request, Object response, Lifecycle lifecycle) throws FacesException {
Util.notNull("sc", sc);
Util.notNull("request", request);
Util.notNull("response", response);
Util.notNull("lifecycle", lifecycle);
ExternalContext extContext;
FacesContext ctx = new FacesContextImpl(extContext = externalContextFactory.getExternalContext(sc, request, response), lifecycle);
ctx.setExceptionHandler(exceptionHandlerFactory.getExceptionHandler());
WebConfiguration webConfig = WebConfiguration.getInstance(extContext);
savePerRequestInitParams(ctx, webConfig);
return ctx;
}
use of com.sun.faces.config.WebConfiguration in project mojarra by eclipse-ee4j.
the class CompositeComponentTagLibrary method init.
private void init() {
WebConfiguration webconfig = WebConfiguration.getInstance();
enableMissingResourceLibraryDetection = webconfig.isOptionEnabled(EnableMissingResourceLibraryDetection);
}
use of com.sun.faces.config.WebConfiguration in project mojarra by eclipse-ee4j.
the class IncludeHandler method apply.
/*
* (non-Javadoc)
*
* @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext, jakarta.faces.component.UIComponent)
*/
@Override
public void apply(FaceletContext ctx, UIComponent parent) throws IOException {
String path = src.getValue(ctx);
if (path == null || path.length() == 0) {
return;
}
VariableMapper orig = ctx.getVariableMapper();
ctx.setVariableMapper(new VariableMapperWrapper(orig));
try {
nextHandler.apply(ctx, null);
WebConfiguration webConfig = WebConfiguration.getInstance();
if (path.startsWith(webConfig.getOptionValue(WebConfiguration.WebContextInitParameter.WebAppContractsDirectory))) {
throw new TagAttributeException(tag, src, "Invalid src, contract resources cannot be accessed this way : " + path);
}
ctx.includeFacelet(parent, path);
} catch (IOException e) {
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE, e.toString(), e);
}
throw new TagAttributeException(tag, src, "Invalid path : " + path);
} finally {
ctx.setVariableMapper(orig);
}
}
use of com.sun.faces.config.WebConfiguration in project mojarra by eclipse-ee4j.
the class CompositionHandler method apply.
/*
* (non-Javadoc)
*
* @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext, jakarta.faces.component.UIComponent)
*/
@Override
public void apply(FaceletContext ctxObj, UIComponent parent) throws IOException {
FaceletContextImplBase ctx = (FaceletContextImplBase) ctxObj;
if (template != null) {
FacesContext facesContext = ctx.getFacesContext();
Integer compositionCount = (Integer) facesContext.getAttributes().get("com.sun.faces.uiCompositionCount");
if (compositionCount == null) {
compositionCount = 1;
} else {
compositionCount++;
}
facesContext.getAttributes().put("com.sun.faces.uiCompositionCount", compositionCount);
VariableMapper orig = ctx.getVariableMapper();
if (params != null) {
VariableMapper vm = new VariableMapperWrapper(orig);
ctx.setVariableMapper(vm);
for (int i = 0; i < params.length; i++) {
params[i].apply(ctx, parent);
}
}
ctx.extendClient(this);
String path = null;
try {
path = template.getValue(ctx);
if (path.trim().length() == 0) {
throw new TagAttributeException(tag, template, "Invalid path : " + path);
}
WebConfiguration webConfig = WebConfiguration.getInstance();
if (path.startsWith(webConfig.getOptionValue(WebConfiguration.WebContextInitParameter.WebAppContractsDirectory))) {
throw new TagAttributeException(tag, template, "Invalid path, contract resources cannot be accessed this way : " + path);
}
ctx.includeFacelet(parent, path);
} catch (IOException e) {
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE, e.toString(), e);
}
throw new TagAttributeException(tag, template, "Invalid path : " + path);
} finally {
ctx.popClient(this);
ctx.setVariableMapper(orig);
compositionCount = (Integer) facesContext.getAttributes().get("com.sun.faces.uiCompositionCount");
compositionCount--;
if (compositionCount == 0) {
facesContext.getAttributes().remove("com.sun.faces.uiCompositionCount");
} else {
facesContext.getAttributes().put("com.sun.faces.uiCompositionCount", compositionCount);
}
}
} else {
nextHandler.apply(ctx, parent);
}
}
use of com.sun.faces.config.WebConfiguration in project mojarra by eclipse-ee4j.
the class Util method checkIdUniqueness.
/**
* Utility method to validate ID uniqueness for the tree represented by <code>component</code>.
*/
public static void checkIdUniqueness(FacesContext context, UIComponent component, Set<String> componentIds) {
boolean uniquenessCheckDisabled = false;
if (context.isProjectStage(ProjectStage.Production)) {
WebConfiguration config = WebConfiguration.getInstance(context.getExternalContext());
uniquenessCheckDisabled = config.isOptionEnabled(WebConfiguration.BooleanWebContextInitParameter.DisableIdUniquenessCheck);
}
if (!uniquenessCheckDisabled) {
// deal with children/facets that are marked transient.
for (Iterator<UIComponent> kids = component.getFacetsAndChildren(); kids.hasNext(); ) {
UIComponent kid = kids.next();
// check for id uniqueness
String id = kid.getClientId(context);
if (componentIds.add(id)) {
checkIdUniqueness(context, kid, componentIds);
} else {
if (LOGGER.isLoggable(Level.SEVERE)) {
LOGGER.log(Level.SEVERE, "faces.duplicate_component_id_error", id);
FastStringWriter writer = new FastStringWriter(128);
DebugUtil.simplePrintTree(context.getViewRoot(), id, writer);
LOGGER.severe(writer.toString());
}
String message = MessageUtils.getExceptionMessageString(MessageUtils.DUPLICATE_COMPONENT_ID_ERROR_ID, id);
throw new IllegalStateException(message);
}
}
}
}
Aggregations