* @see javax.faces.view.facelets.FaceletHandler#apply(javax.faces.view.facelets.FaceletContext, javax.faces.component.UIComponent)
*/
public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
ELException
{
UIViewRoot root = ComponentSupport.getViewRoot(ctx, parent);
if (root != null)
{
if (this.locale != null)
{
root.setLocale(ComponentSupport.getLocale(ctx, this.locale));
}
if (this.renderKitId != null)
{
String v = this.renderKitId.getValue(ctx);
root.setRenderKitId(v);
}
String encodingValue = null;
if (this.contentType != null)
{
// This value is read as rfc2616 section 3.7 Media Types.
// We should check and extract the param "charset" and assing
// it as encoding for this page.
String v = this.contentType.getValue(ctx);
if (v != null)
{
int j = v.indexOf(';');
if (j >= 0)
{
int i = v.indexOf("charset",j);
if (i >= 0)
{
i = v.indexOf('=',i)+1;
if (v.length() > i)
{
encodingValue = v.substring(i);
}
// Substract charset from encoding, it will be added
// later on FaceletViewDeclarationLanguage.createResponseWriter
// by calling response.setContentType
v = v.substring(0 , j);
}
}
}
ctx.getFacesContext().getExternalContext().getRequestMap().put("facelets.ContentType", v);
}
if (this.encoding != null)
{
String v = this.encoding.getValue(ctx);
ctx.getFacesContext().getExternalContext().getRequestMap().put("facelets.Encoding", v);
}
else if (encodingValue != null)
{
ctx.getFacesContext().getExternalContext().getRequestMap().put("facelets.Encoding", encodingValue);
}
if (this.beforePhase != null)
{
MethodExpression m = this.beforePhase.getMethodExpression(ctx, null, LISTENER_SIG);
root.setBeforePhaseListener(m);
}
if (this.afterPhase != null)
{
MethodExpression m = this.afterPhase.getMethodExpression(ctx, null, LISTENER_SIG);
root.setAfterPhaseListener(m);
}
}
this.nextHandler.apply(ctx, parent);
}