*/
public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
ELException
{
AbstractFaceletContext actx = (AbstractFaceletContext) ctx;
FaceletCompositionContext fcc = FaceletCompositionContext.getCurrentInstance(ctx);
String path;
if (!src.isLiteral())
{
String uniqueId = fcc.startComponentUniqueIdSection();
path = getSrcValue(actx, fcc, parent, uniqueId);
ComponentSupport.saveInitialTagState(ctx, fcc, parent, uniqueId, path);
}
else
{
path = this.src.getValue(ctx);
}
try
{
if (path == null || path.length() == 0)
{
return;
}
VariableMapper orig = ctx.getVariableMapper();
ctx.setVariableMapper(new VariableMapperWrapper(orig));
try
{
//Only ui:param could be inside ui:include.
//this.nextHandler.apply(ctx, null);
URL url = null;
// if we are in ProjectStage Development and the path equals "javax.faces.error.xhtml"
// we should include the default error page
if (ctx.getFacesContext().isProjectStage(ProjectStage.Development)
&& ERROR_PAGE_INCLUDE_PATH.equals(path))
{
url =ClassUtils.getResource(ERROR_FACELET);
}
try
{
if (_params != null)
{
// ui:include defines a new TemplateContext, but ui:param EL expressions
// defined inside should be built before the new context is setup, to
// apply then after. The final effect is EL expressions will be resolved
// correctly when nested ui:params with the same name or based on other
// ui:params are used.
String[] names = new String[_params.length];
ValueExpression[] values = new ValueExpression[_params.length];
for (int i = 0; i < _params.length; i++)
{
names[i] = _params[i].getName(ctx);
values[i] = _params[i].getValue(ctx);
}
actx.pushTemplateContext(new TemplateContextImpl());
for (int i = 0; i < _params.length; i++)
{
_params[i].apply(ctx, parent, names[i], values[i]);
}
}
else
{
actx.pushTemplateContext(new TemplateContextImpl());
}
if (url == null)
{
ctx.includeFacelet(parent, path);
}
else
{
ctx.includeFacelet(parent, url);
}
}
finally
{
actx.popTemplateContext();
}
}
finally
{
ctx.setVariableMapper(orig);
}
}
finally
{
if (!src.isLiteral())
{
fcc.endComponentUniqueIdSection();
}
}
if (!src.isLiteral() && fcc.isUsingPSSOnThisView() && fcc.isRefreshTransientBuildOnPSS() &&
!fcc.isRefreshingTransientBuild())
{
//Mark the parent component to be saved and restored fully.
ComponentSupport.markComponentToRestoreFully(ctx.getFacesContext(), parent);
}
}