use of com.sun.faces.facelets.impl.DefaultFaceletFactory in project mojarra by eclipse-ee4j.
the class ApplicationAssociate method createFaceletFactory.
protected DefaultFaceletFactory createFaceletFactory(FacesContext context, Compiler compiler, WebConfiguration webConfig) {
// refresh period
boolean isProduction = applicationImpl.getProjectStage() == Production;
String refreshPeriod;
if (webConfig.isSet(FaceletsDefaultRefreshPeriod)) {
refreshPeriod = webConfig.getOptionValue(FaceletsDefaultRefreshPeriod);
} else if (isProduction) {
refreshPeriod = "-1";
} else {
refreshPeriod = FaceletsDefaultRefreshPeriod.getDefaultValue();
}
long period = parseLong(refreshPeriod);
// resource resolver
DefaultResourceResolver resolver = new DefaultResourceResolver(applicationImpl.getResourceHandler());
FaceletCacheFactory cacheFactory = (FaceletCacheFactory) FactoryFinder.getFactory(FACELET_CACHE_FACTORY);
FaceletCache<?> cache = cacheFactory.getFaceletCache();
DefaultFaceletFactory toReturn = new DefaultFaceletFactory();
toReturn.init(context, compiler, resolver, period, cache);
return toReturn;
}
use of com.sun.faces.facelets.impl.DefaultFaceletFactory in project mojarra by eclipse-ee4j.
the class FaceletViewHandlingStrategy method createComponentMetadata.
private BeanInfo createComponentMetadata(FacesContext context, Resource ccResource) {
// PENDING this implementation is terribly wasteful.
// Must find a better way.
FaceletContext faceletContext = (FaceletContext) context.getAttributes().get(FACELET_CONTEXT_KEY);
DefaultFaceletFactory factory = (DefaultFaceletFactory) RequestStateManager.get(context, FACELET_FACTORY);
VariableMapper orig = faceletContext.getVariableMapper();
// Create tmp and facetComponent
UIComponent tmp = context.getApplication().createComponent("jakarta.faces.NamingContainer");
UIPanel facetComponent = (UIPanel) context.getApplication().createComponent("jakarta.faces.Panel");
// PENDING I think this can be skipped because we don't render
// this component instance.
facetComponent.setRendererType("jakarta.faces.Group");
// PENDING This could possibly be skipped too. However, I think
// this is important because other tag handlers, within
// <cc:interface> expect it will be there.
tmp.getFacets().put(COMPOSITE_FACET_NAME, facetComponent);
// We have to put the resource in here just so the classes that eventually
// get called by facelets have access to it.
tmp.getAttributes().put(COMPONENT_RESOURCE_KEY, ccResource);
Facelet facelet;
try {
facelet = factory.getFacelet(context, ccResource.getURL());
VariableMapper wrapper = new VariableMapperWrapper(orig) {
@Override
public ValueExpression resolveVariable(String variable) {
// PENDING is this needed?
return super.resolveVariable(variable);
}
};
faceletContext.setVariableMapper(wrapper);
context.getAttributes().put(IS_BUILDING_METADATA, TRUE);
// Because mojarra currently requires a <cc:interface>
// element within the compcomp markup, we can rely on the
// fact that its tag handler, InterfaceHandler.apply(), is
// called. In this method, we first imbue facetComponent
// with any config information present on the <cc:interface>
// element.
// Then we do the normal facelet thing:
// this.nextHandler.apply(). This causes any child tag
// handlers of the <cc:interface> to be called. The
// compcomp spec says each such tag handler is responsible
// for adding to the compcomp metadata, referenced from the
// facetComponent parent.
facelet.apply(context, facetComponent);
// When facelet.apply() returns (and therefore
// InterfaceHandler.apply() returns), the compcomp metadata
// pointed to by facetComponent is fully populated.
} catch (Exception e) {
if (e instanceof FacesException) {
throw (FacesException) e;
} else {
throw new FacesException(e);
}
} finally {
context.getAttributes().remove(IS_BUILDING_METADATA);
faceletContext.setVariableMapper(orig);
}
// not yet implemented.
return (CompositeComponentBeanInfo) tmp.getAttributes().get(BEANINFO_KEY);
}
Aggregations