/* (non-Javadoc)
   * @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
   */
  public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
    //
    UIAjaxOutputPanel panel = (UIAjaxOutputPanel) component;
    if ("none".equals(panel.getLayout())) {
      if (component.getChildCount() > 0) {
        AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
        boolean ajaxRequest = ajaxContext.isAjaxRequest();
        Set<String> ajaxRenderedAreas = ajaxContext.getAjaxRenderedAreas();
        for (UIComponent child : component.getChildren()) {
          String childId = child.getClientId(context);
          if (child.isRendered()) {
            renderChild(context, child);
          } else {
            // Render "dummy" span.
            ResponseWriter out = context.getResponseWriter();
            out.startElement(HTML.SPAN_ELEM, child);
            out.writeAttribute(HTML.id_ATTRIBUTE, childId, HTML.id_ATTRIBUTE);
            out.writeAttribute(HTML.style_ATTRIBUTE, "display: none;", "style");
            out.endElement(HTML.SPAN_ELEM);
          }
          // register child as rendered
          if (ajaxRequest && null != ajaxRenderedAreas) {
            ajaxRenderedAreas.add(childId);
          }
        }
      }

    } else {
      renderChildren(context, component);
    }
  }