Copied from com.sun.faces.context.PartialViewContextImpl. May have to be adapted to future Mojarra or JSF versions.
558165
private void renderState(FacesContext context) throws IOException {
		// Get the view state and write it to the response..
		PartialViewContext pvc = context.getPartialViewContext();
		PartialResponseWriter writer = pvc.getPartialResponseWriter();
		String viewStateId = Util.getViewStateId(context);

		writer.startUpdate(viewStateId);
		String state = context.getApplication().getStateManager().getViewState(context);
		writer.write(state);
		writer.endUpdate();

		ClientWindow window = context.getExternalContext().getClientWindow();
		if (null != window) {
			String clientWindowId = Util.getClientWindowId(context);
			writer.startUpdate(clientWindowId);
			writer.write(window.getId());
			writer.endUpdate();
		}
	}
1340859
private Component prepareCategoryFacets(CmsSolrResultList solrResultList, CmsSearchResultWrapper resultWrapper) {

        FacetField categoryFacets = solrResultList.getFacetField(CmsListManager.FIELD_CATEGORIES);
        I_CmsSearchControllerFacetField facetController = resultWrapper.getController().getFieldFacets().getFieldFacetController().get(
            CmsListManager.FIELD_CATEGORIES);
        if ((categoryFacets != null) && (categoryFacets.getValueCount() > 0)) {
            VerticalLayout catLayout = new VerticalLayout();
            for (final Count value : categoryFacets.getValues()) {
                Button cat = new Button(getCategoryLabel(value.getName()) + " (" + value.getCount() + ")");
                cat.addStyleName(ValoTheme.BUTTON_TINY);
                cat.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                Boolean selected = facetController.getState().getIsChecked().get(value.getName());
                if ((selected != null) && selected.booleanValue()) {
                    cat.addStyleName(SELECTED_STYLE);
                }
                cat.addClickListener(new ClickListener() {

                    private static final long serialVersionUID = 1L;

                    public void buttonClick(ClickEvent event) {

                        if (isSelected(event.getComponent())) {
                            resetFacetsAndSearch();
                        } else {
                            selectFieldFacet(CmsListManager.FIELD_CATEGORIES, value.getName());
                        }
                    }
                });
                catLayout.addComponent(cat);
            }
            Panel catPanel = new Panel(CmsVaadinUtils.getMessageText(Messages.GUI_LISTMANAGER_FACET_CATEGORIES_0));
            catPanel.setContent(catLayout);
            return catPanel;
        } else {
            return null;
        }
    }
369862
@Override
	public void decode(FacesContext context, UIComponent component) {
		ScrollSpy ss = (ScrollSpy) component;
		super.decode(context, ss);

		final ScrollSpyEventListener selectionListener = ss.getSelectionListener();
		String params = context.getExternalContext().getRequestParameterMap().get("params");
		if (params != null && selectionListener != null) {
			if (params != null) {
				params = params.replace("BsFEvent=", "");
				String[] pair = params.split(":", 2);
				String key = pair[0];
				String value = null;
				if (pair.length == 2) {
					value = pair[1];
				}
				if (value != null) {
					if ("itemSelected".equals(key)) {
						selectionListener.itemSelected(value);
					} else {
						throw new FacesException("Unexpected event when trying to decode the scrollspy event: " + key);
					}
				}
			}
		}
	}
341738
@Override
	public void decode(FacesContext context, UIComponent component) {
		SelectOneMenu menu = (SelectOneMenu) component;
		if (menu.isDisabled() || menu.isReadonly()) {
			return;
		}
		String outerClientId = menu.getClientId(context);
		String clientId = outerClientId + "Inner";
		String submittedOptionValue = (String) context.getExternalContext().getRequestParameterMap().get(clientId);

		Converter converter = menu.getConverter();
		if (null == converter) {
			converter = findImplicitConverter(context, component);
		}
		List<SelectItemAndComponent> items = SelectItemUtils.collectOptions(context, menu, converter);

		if (null != submittedOptionValue) {
			for (int index = 0; index < items.size(); index++) {
				Object currentOption = items.get(index).getSelectItem();
				String currentOptionValueAsString;
				Object currentOptionValue = null;
				if (currentOption instanceof SelectItem) {
					if (!((SelectItem) currentOption).isDisabled()) {
						currentOptionValue = ((SelectItem) currentOption).getValue();
					}
				}
				if (currentOptionValue instanceof String) {
					currentOptionValueAsString = (String) currentOptionValue;
				} else if (null != converter) {
					currentOptionValueAsString = converter.getAsString(context, component, currentOptionValue);
				} else if (currentOptionValue != null) {
					currentOptionValueAsString = String.valueOf(index);
				} else {
					currentOptionValueAsString = ""; // null values are submitted as empty strings
				}
				if (submittedOptionValue.equals(currentOptionValueAsString)) {
					Object submittedValue = null;
					if (currentOptionValue == null) {
						submittedValue = null;
					} else {
						submittedValue = null != converter ? currentOptionValueAsString : currentOptionValue;
					}
					menu.setSubmittedValue(submittedValue);
					menu.setValid(true);
					
					menu.validateValue(context, submittedValue);
					new AJAXRenderer().decode(context, component, clientId);
					if (menu.isValid()) {
						if (currentOptionValue == null)  {
							menu.setLocalValueSet(true);
						}
					}
					return;
				}
			}
			menu.validateValue(context, null);
			menu.setSubmittedValue(null);
			menu.setValid(false);
			return;
		}

		menu.setValid(true);
		menu.validateValue(context, submittedOptionValue);
		menu.setSubmittedValue(submittedOptionValue);
		new AJAXRenderer().decode(context, component, clientId);
	}
650751
@Override
	protected void render(FacesContext context) throws IOException {

		// Generate the name definition or image element
		StringBuffer results = new StringBuffer(getElementOpen());

		prepareImageUrl(context, results);

		prepareAttribute(results, "name", getAttribute("name"));
		prepareAttribute(results, "align", getAttribute("align"));
		prepareAttribute(results, "border", getAttribute("border"));
		prepareAttribute(results, "value", getAttribute("value"));
		prepareAttribute(results, "accesskey", getAttribute("accesskey"));
		prepareAttribute(results, "tabindex", getAttribute("tabindex"));
		prepareAttribute(results, "disabled", getAttribute("disabled"));
		results.append(prepareStyles());
		results.append(prepareEventHandlers());
		results.append(" />");

		ResponseWriter writer = context.getResponseWriter();
		writer.write(results.toString());
	}
417864
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		AbstractWFieldIndicator fieldIndicator = (AbstractWFieldIndicator) component;
		XmlStringBuilder xml = renderContext.getWriter();

		WComponent validationTarget = fieldIndicator.getTargetComponent();

		// no need to render an indicator for nothing.
		// Diagnosables takes care of thieir own  messaging.
		if (validationTarget == null || (validationTarget instanceof Diagnosable && !(validationTarget instanceof Input))) {
			return;
		}

		if (validationTarget instanceof Input && !((Input) validationTarget).isReadOnly()) {
			return;
		}

		List<Diagnostic> diags = fieldIndicator.getDiagnostics();

		if (diags != null && !diags.isEmpty()) {
			xml.appendTagOpen("ui:fieldindicator");
			xml.appendAttribute("id", component.getId());
			xml.appendOptionalAttribute("track", component.isTracking(), "true");

			switch (fieldIndicator.getFieldIndicatorType()) {
				case INFO:
					xml.appendAttribute("type", "info");
					break;

				case WARN:
					xml.appendAttribute("type", "warn");
					break;

				case ERROR:
					xml.appendAttribute("type", "error");
					break;

				default:
					throw new SystemException("Cannot paint field indicator due to an invalid field indicator type: "
							+ fieldIndicator.getFieldIndicatorType());
			}

			xml.appendAttribute("for", fieldIndicator.getRelatedFieldId());
			xml.appendClose();

			for (Diagnostic diag : diags) {
				xml.appendTag("ui:message");
				xml.appendEscaped(diag.getDescription());
				xml.appendEndTag("ui:message");
			}

			xml.appendEndTag("ui:fieldindicator");
		}
	}
275750
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WLink link = (WLink) component;
		XmlStringBuilder xml = renderContext.getWriter();
		String text = link.getText();
		String targetWindowName = link.getOpenNewWindow() ? link.getTargetWindowName() : null;
		String imageUrl = link.getImageUrl();

		xml.appendTagOpen("ui:link");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		xml.appendOptionalAttribute("disabled", link.isDisabled(), "true");
		xml.appendOptionalAttribute("hidden", component.isHidden(), "true");
		xml.appendOptionalAttribute("toolTip", link.getToolTip());
		xml.appendOptionalAttribute("accessibleText", link.getAccessibleText());
		xml.appendUrlAttribute("url", link.getUrl());
		xml.appendOptionalAttribute("rel", link.getRel());
		xml.appendOptionalAttribute("accessKey", Util.upperCase(link.getAccessKeyAsString()));

		if (imageUrl != null) {
			xml.appendUrlAttribute("imageUrl", imageUrl);
			ImagePosition imagePosition = link.getImagePosition();

			if (imagePosition != null) {
				switch (imagePosition) {
					case NORTH:
						xml.appendAttribute("imagePosition", "n");
						break;
					case EAST:
						xml.appendAttribute("imagePosition", "e");
						break;
					case SOUTH:
						xml.appendAttribute("imagePosition", "s");
						break;
					case WEST:
						xml.appendAttribute("imagePosition", "w");
						break;
					default:
						throw new SystemException("Unknown image position: " + imagePosition);
				}
			}
			// we have an image. We must have a text equivalent
			if (Util.empty(text) && Util.empty(link.getToolTip()) && Util.empty(link.getAccessibleText())) {
				// If the link has an umageUrl but no text equivalent get the text equivalent off of the image
				WImage linkImage = link.getImageHolder();
				if (null != linkImage) {
					xml.appendOptionalAttribute("toolTip", linkImage.getAlternativeText());
				}
			}
		}

		if (link.isRenderAsButton()) {
			xml.appendAttribute("type", "button");
		}

		xml.appendClose();

		if (targetWindowName != null) {
			xml.appendTagOpen("ui:windowAttributes");
			xml.appendAttribute("name", targetWindowName);

			WLink.WindowAttributes attributes = link.getWindowAttrs();

			if (attributes != null) {
				xml.appendOptionalAttribute("top", attributes.getTop() >= 0, attributes.getTop());
				xml.appendOptionalAttribute("left", attributes.getLeft() >= 0, attributes.getLeft());
				xml.appendOptionalAttribute("width", attributes.getWidth() > 0, attributes.
						getWidth());
				xml.appendOptionalAttribute("height", attributes.getHeight() > 0, attributes.
						getHeight());
				xml.appendOptionalAttribute("resizable", attributes.isResizable(), "true");
				xml.appendOptionalAttribute("showMenubar", attributes.isMenubar(), "true");
				xml.appendOptionalAttribute("showToolbar", attributes.isToolbars(), "true");
				xml.appendOptionalAttribute("showLocation", attributes.isLocation(), "true");
				xml.appendOptionalAttribute("showStatus", attributes.isStatus(), "true");
				xml.appendOptionalAttribute("showScrollbars", attributes.isScrollbars(), "true");
				xml.appendOptionalAttribute("showDirectories", attributes.isDirectories(), "true");
			}

			xml.appendEnd();
		}

		if (text != null) {
			xml.appendEscaped(text);
		}

		xml.appendEndTag("ui:link");

		// Paint the AJAX trigger if the link has an action
		if (link.getAction() != null) {
			paintAjaxTrigger(link, xml);
		}

	}
1342430
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WFieldLayout fieldLayout = (WFieldLayout) component;
		XmlStringBuilder xml = renderContext.getWriter();
		int labelWidth = fieldLayout.getLabelWidth();
		String title = fieldLayout.getTitle();

		xml.appendTagOpen("ui:fieldlayout");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		xml.appendOptionalAttribute("hidden", fieldLayout.isHidden(), "true");
		xml.appendOptionalAttribute("labelWidth", labelWidth > 0, labelWidth);
		xml.appendAttribute("layout", fieldLayout.getLayoutType());
		xml.appendOptionalAttribute("title", title);
		// Ordered layout
		if (fieldLayout.isOrdered()) {
			xml.appendAttribute("ordered", fieldLayout.getOrderedOffset());
		}
		xml.appendClose();

		// Render margin
		MarginRendererUtil.renderMargin(fieldLayout, renderContext);

		// Paint Fields
		paintChildren(fieldLayout, renderContext);

		xml.appendEndTag("ui:fieldlayout");
	}
1148169
@Override
	protected BundleRenderer createRenderer(FacesContext context) {

		ResourceBundlesHandler rsHandler = getResourceBundlesHandler(context);
		String type = (String) getAttributes().get(JawrConstant.TYPE_ATTR);
		boolean async = Boolean.parseBoolean((String) getAttributes().get(JawrConstant.ASYNC_ATTR));
		boolean defer = Boolean.parseBoolean((String) getAttributes().get(JawrConstant.DEFER_ATTR));
		String crossorigin = (String) getAttributes().get(JawrConstant.CROSSORIGIN_ATTR);
		return RendererFactory.getJsBundleRenderer(rsHandler, type, getUseRandomParamFlag(rsHandler.getConfig()), async,
				defer, crossorigin);
	}
43622
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WPanel panel = (WPanel) component;
		XmlStringBuilder xml = renderContext.getWriter();
		ColumnLayout layout = (ColumnLayout) panel.getLayout();
		int childCount = panel.getChildCount();
		Size hgap = layout.getHorizontalGap();
		String hgapString = hgap == null ? null : hgap.toString();
		Size vgap = layout.getVerticalGap();
		String vgapString = vgap == null ? null : vgap.toString();
		int cols = layout.getColumnCount();

		xml.appendTagOpen("ui:columnlayout");
		xml.appendOptionalAttribute("hgap", hgapString);
		xml.appendOptionalAttribute("vgap", vgapString);
		xml.appendClose();

		// Column Definitions
		for (int col = 0; col < cols; col++) {
			xml.appendTagOpen("ui:column");
			int width = layout.getColumnWidth(col);
			xml.appendOptionalAttribute("width", width > 0, width);

			switch (layout.getColumnAlignment(col)) {
				case LEFT:
					// left is assumed if omitted
					break;

				case RIGHT:
					xml.appendAttribute("align", "right");
					break;

				case CENTER:
					xml.appendAttribute("align", "center");
					break;

				default:
					throw new IllegalArgumentException("Invalid alignment: " + layout.
							getColumnAlignment(col));
			}

			xml.appendEnd();
		}

		for (int i = 0; i < childCount; i++) {
			xml.appendTag("ui:cell");
			WComponent child = panel.getChildAt(i);
			child.paint(renderContext);
			xml.appendEndTag("ui:cell");
		}

		xml.appendEndTag("ui:columnlayout");
	}
879629
@Override
	protected BundleRenderer createRenderer(FacesContext context) {

		ResourceBundlesHandler rsHandler = getResourceBundlesHandler(context);

		String media = (String) getAttributes().get(JawrConstant.MEDIA_ATTR);
		boolean alternate = Boolean.parseBoolean((String) getAttributes().get(JawrConstant.ALTERNATE_ATTR));
		boolean displayAlternate = Boolean
				.parseBoolean((String) getAttributes().get(JawrConstant.DISPLAY_ALTERNATE_ATTR));
		String title = (String) getAttributes().get(JawrConstant.TITLE_ATTR);

		return RendererFactory.getCssBundleRenderer(rsHandler, getUseRandomParamFlag(rsHandler.getConfig()), media,
				alternate, displayAlternate, title);
	}
899201
public String getToViewId(FacesContext context) {

        if (toViewIdExpr == null) {
            ExpressionFactory factory =
                  context.getApplication().getExpressionFactory();
            toViewIdExpr = factory.createValueExpression(context.getELContext(),
                                                         toViewId,
                                                         String.class);
        }
        String result = (String) toViewIdExpr.getValue(context.getELContext());
        if (result.charAt(0) != '/') {
            result = '/' + result;
        }

        return result;

    }
873366
public void validate(FacesContext context,
                         UIComponent  component,
                         Object       value) throws ValidatorException {
	if (null == context || null == component) {
	    throw new NullPointerException();
	}
        try {
            methodBinding.invoke(context, new Object[] {context, component, 
							value});
        } 
	catch (EvaluationException ee) {
	    Throwable cause = this.getExpectedCause(ValidatorException.class,
						    ee);
	    if (cause instanceof ValidatorException) {
		throw ((ValidatorException) cause);
	    }
	    if (cause instanceof RuntimeException) {
		throw ((RuntimeException) cause);
	    }
	    throw new IllegalStateException(ee);
        }
	
	
    }
1102938
protected void renderTextAreaBegin(FacesContext facesContext,
            UIComponent uiComponent) throws IOException
    {
        ResponseWriter writer = facesContext.getResponseWriter();
        writer.startElement(HTML.TEXTAREA_ELEM, uiComponent);

        Map<String, List<ClientBehavior>> behaviors = null;
        if (uiComponent instanceof ClientBehaviorHolder)
        {
            behaviors = ((ClientBehaviorHolder) uiComponent).getClientBehaviors();
            if (!behaviors.isEmpty())
            {
                HtmlRendererUtils.writeIdAndName(writer, uiComponent, facesContext);
            }
            else
            {
                HtmlRendererUtils.writeIdIfNecessary(writer, uiComponent, facesContext);
                writer.writeAttribute(HTML.NAME_ATTR, uiComponent.getClientId(facesContext), null);
            }
            long commonPropertiesMarked = 0L;
            if (isCommonPropertiesOptimizationEnabled(facesContext))
            {
                commonPropertiesMarked = CommonPropertyUtils.getCommonPropertiesMarked(uiComponent);
            }
            if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(facesContext))
            {
                CommonPropertyUtils.renderChangeEventProperty(writer, 
                        commonPropertiesMarked, uiComponent);
                CommonPropertyUtils.renderEventProperties(writer, 
                        commonPropertiesMarked, uiComponent);
                CommonPropertyUtils.renderFieldEventPropertiesWithoutOnchange(writer, 
                        commonPropertiesMarked, uiComponent);
            }
            else
            {
                HtmlRendererUtils.renderBehaviorizedOnchangeEventHandler(facesContext, writer, uiComponent, behaviors);
                if (isCommonEventsOptimizationEnabled(facesContext))
                {
                    Long commonEventsMarked = CommonEventUtils.getCommonEventsMarked(uiComponent);
                    CommonEventUtils.renderBehaviorizedEventHandlers(facesContext, writer, 
                            commonPropertiesMarked, commonEventsMarked, uiComponent, behaviors);
                    CommonEventUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(
                        facesContext, writer, commonPropertiesMarked, commonEventsMarked, uiComponent, behaviors);
                }
                else
                {
                    HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, uiComponent, behaviors);
                    HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(
                            facesContext, writer, uiComponent, behaviors);
                }
            }
            if (isCommonPropertiesOptimizationEnabled(facesContext))
            {
                CommonPropertyUtils.renderCommonFieldPassthroughPropertiesWithoutDisabledAndEvents(writer, 
                        CommonPropertyUtils.getCommonPropertiesMarked(uiComponent), uiComponent);
                HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.TEXTAREA_ATTRIBUTES);
            }
            else
            {
                HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, 
                        HTML.TEXTAREA_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_EVENTS);
            }
        }
        else
        {
            HtmlRendererUtils.writeIdIfNecessary(writer, uiComponent, facesContext);
            writer.writeAttribute(HTML.NAME_ATTR, uiComponent.getClientId(facesContext), null);
            if (isCommonPropertiesOptimizationEnabled(facesContext))
            {
                CommonPropertyUtils.renderCommonFieldPassthroughPropertiesWithoutDisabled(writer, 
                        CommonPropertyUtils.getCommonPropertiesMarked(uiComponent), uiComponent);
                HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.TEXTAREA_ATTRIBUTES);
            }
            else
            {
                HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, 
                        HTML.TEXTAREA_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
            }
        }

        if (isDisabled(facesContext, uiComponent))
        {
            writer.writeAttribute(org.apache.myfaces.shared.renderkit.html.HTML.DISABLED_ATTR, Boolean.TRUE, null);
        }
    }
515059
@Override
	public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
		if (!component.isRendered()) {
			return;
		}
		FetchBeanInfos fetchBeanInfos = (FetchBeanInfos) component;
		ResponseWriter rw = context.getResponseWriter();
		String clientId = fetchBeanInfos.getClientId();

		boolean validationFailed = context.isValidationFailed();
		Severity maximumSeverity = context.getMaximumSeverity();
		String maximum="null";
		if (maximumSeverity!=null) {
			maximum=String.valueOf(maximumSeverity.getOrdinal());
		}
		String variables = "bfMaximumMessageSeverity=" + maximum + ";";
		boolean hasFatalError = false;
		boolean hasError = false;
		boolean hasWarning = false;
		boolean hasInfo = false;
		List<FacesMessage> messageList = context.getMessageList();
		for (FacesMessage message : messageList) {
			if (FacesMessage.SEVERITY_FATAL.equals(message.getSeverity())) {
				hasFatalError = true;
			} else if (FacesMessage.SEVERITY_ERROR.equals(message.getSeverity())) {
				hasError = true;
			} else if (FacesMessage.SEVERITY_WARN.equals(message.getSeverity())) {
				hasWarning = true;
			} else if (FacesMessage.SEVERITY_INFO.equals(message.getSeverity())) {
				hasInfo = true;
			}
		}
		variables += "bfHasFatalError=" + hasFatalError + ";";
		variables += "bfHasError=" + hasError + ";";
		variables += "bfHasWarning=" + hasWarning + ";";
		variables += "bfHasInfo=" + hasInfo + ";";

		rw.startElement("script", fetchBeanInfos);
		rw.writeAttribute("id", clientId, null);
		rw.writeText("validationFailed=" + validationFailed + ";" + variables, null);
		rw.endElement("script");
	}
496274
@Override
    public FacesConfig getMetaInfServicesFacesConfig(ExternalContext ectx)
    {
        try
        {
            org.apache.myfaces.config.impl.digester.elements.FacesConfigImpl facesConfig
                    = new org.apache.myfaces.config.impl.digester.elements.FacesConfigImpl();
            org.apache.myfaces.config.impl.digester.elements.FactoryImpl factory
                    = new org.apache.myfaces.config.impl.digester.elements.FactoryImpl();
            
            facesConfig.addFactory(factory);
            
            for (String factoryName : FACTORY_NAMES)
            {
                List<String> classList = ServiceProviderFinderFactory.getServiceProviderFinder(ectx)
                        .getServiceProviderList(factoryName);
                
                for (String className : classList)
                {
                    if (log.isLoggable(Level.INFO))
                    {
                        log.info("Found " + factoryName + " factory implementation: " + className);
                    }

                    if (factoryName.equals(FactoryFinder.APPLICATION_FACTORY))
                    {
                        factory.addApplicationFactory(className);
                    } 
                    else if(factoryName.equals(FactoryFinder.EXCEPTION_HANDLER_FACTORY)) 
                    {
                        factory.addExceptionHandlerFactory(className);
                    } 
                    else if (factoryName.equals(FactoryFinder.EXTERNAL_CONTEXT_FACTORY))
                    {
                        factory.addExternalContextFactory(className);
                    } 
                    else if (factoryName.equals(FactoryFinder.FACES_CONTEXT_FACTORY))
                    {
                        factory.addFacesContextFactory(className);
                    } 
                    else if (factoryName.equals(FactoryFinder.LIFECYCLE_FACTORY))
                    {
                        factory.addLifecycleFactory(className);
                    } 
                    else if (factoryName.equals(FactoryFinder.RENDER_KIT_FACTORY))
                    {
                        factory.addRenderkitFactory(className);
                    } 
                    else if(factoryName.equals(FactoryFinder.TAG_HANDLER_DELEGATE_FACTORY)) 
                    {
                        factory.addTagHandlerDelegateFactory(className);
                    } 
                    else if (factoryName.equals(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY))
                    {
                        factory.addPartialViewContextFactory(className);
                    } 
                    else if(factoryName.equals(FactoryFinder.VISIT_CONTEXT_FACTORY)) 
                    {
                        factory.addVisitContextFactory(className);
                    } 
                    else if(factoryName.equals(FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY)) 
                    {
                        factory.addViewDeclarationLanguageFactory(className);
                    }
                    else if(factoryName.equals(FactoryFinder.FLASH_FACTORY)) 
                    {
                        factory.addFlashFactory(className);
                    }
                    else if(factoryName.equals(FactoryFinder.FLOW_HANDLER_FACTORY)) 
                    {
                        factory.addFlowHandlerFactory(className);
                    }
                    else if(factoryName.equals(FactoryFinder.CLIENT_WINDOW_FACTORY)) 
                    {
                        factory.addClientWindowFactory(className);
                    }
                    else if(factoryName.equals(FactoryFinder.FACELET_CACHE_FACTORY)) 
                    {
                        factory.addFaceletCacheFactory(className);
                    }
                    else
                    {
                        throw new IllegalStateException("Unexpected factory name " + factoryName);
                    }
                }
            }
            return facesConfig;
        }
        catch (Throwable e)
        {
            throw new FacesException(e);
        }
    }
414518
@Override
    public boolean getRendersChildren() {
        boolean value = super.getRendersChildren();
        FacesContext context = FacesContext.getCurrentInstance();

        if (context.getPartialViewContext().isAjaxRequest()) {
            value = true;
        }
        return value;
    }