private void _encodeAllPositioned()

in trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/PanelBorderLayoutRenderer.java [717:846]


  private void _encodeAllPositioned(
    FacesContext     context,
    RenderingContext rc,
    UIComponent      component,
    FacesBean        bean
    ) throws IOException
  {
    ResponseWriter writer = context.getResponseWriter();

    // IE6 does not support stretching by setting both top & bottom or left & right,
    // so we have to use some ugly code.
    TrinidadAgent agent = (TrinidadAgent)rc.getAgent();
    boolean isIE6 = Agent.AGENT_IE.equals(agent.getAgentName()) &&
      agent.getAgentMajorVersion() == 6;
    if (isIE6)
    {
      // send down the JS that we need to stretch the components
      XhtmlUtils.addLib(context, rc, PanelBorderIE6Scriptlet.sharedInstance().getScriptletKey());
    }

    writer.startElement("div", component);
    renderId(context, component);
    if (isIE6)
    {
      writer.writeAttribute("onresize", "TrPanelBorderLayoutResizeIE6(this)", null);
    }
    renderAllAttributes(context, rc, component, bean);

    UIComponent topFacet = getFacet(component, CorePanelBorderLayout.TOP_FACET);
    UIComponent bottomFacet = getFacet(component, CorePanelBorderLayout.BOTTOM_FACET);
    UIComponent leftFacet = getFacet(component, CorePanelBorderLayout.LEFT_FACET);
    UIComponent rightFacet = getFacet(component, CorePanelBorderLayout.RIGHT_FACET);
    UIComponent innerTopFacet = getFacet(component, CorePanelBorderLayout.INNER_TOP_FACET);
    UIComponent innerBottomFacet = getFacet(component, CorePanelBorderLayout.INNER_BOTTOM_FACET);
    UIComponent innerLeftFacet = getFacet(component, CorePanelBorderLayout.INNER_LEFT_FACET);
    UIComponent innerRightFacet = getFacet(component, CorePanelBorderLayout.INNER_RIGHT_FACET);

    // Don't make room for non-rendered facets
    if (topFacet != null && !topFacet.isRendered()) topFacet = null;
    if (bottomFacet != null && !bottomFacet.isRendered()) bottomFacet = null;
    if (innerTopFacet != null && !innerTopFacet.isRendered()) innerTopFacet = null;
    if (innerBottomFacet != null && !innerBottomFacet.isRendered()) innerBottomFacet = null;

    boolean useLR = leftFacet != null || rightFacet != null
      || innerLeftFacet != null || innerRightFacet != null;
    boolean ltr = !rc.isRightToLeft();

    if (!useLR)
    {
      leftFacet = getFacet(component, ltr ?
        CorePanelBorderLayout.START_FACET : CorePanelBorderLayout.END_FACET);
      innerLeftFacet = getFacet(component, ltr ?
        CorePanelBorderLayout.INNER_START_FACET : CorePanelBorderLayout.INNER_END_FACET);
      rightFacet = getFacet(component, ltr ?
        CorePanelBorderLayout.END_FACET : CorePanelBorderLayout.START_FACET);
      innerRightFacet = getFacet(component, ltr ?
        CorePanelBorderLayout.INNER_END_FACET : CorePanelBorderLayout.INNER_START_FACET);
    }
    // Don't make room for non-rendered facets
    if (innerLeftFacet != null && !innerLeftFacet.isRendered()) innerLeftFacet = null;
    if (innerRightFacet != null && !innerRightFacet.isRendered()) innerRightFacet = null;
    if (innerLeftFacet != null && !innerLeftFacet.isRendered()) innerLeftFacet = null;
    if (innerRightFacet != null && !innerRightFacet.isRendered()) innerRightFacet = null;

    String topHeight = (topFacet == null) ? "0px" : getTopHeight(component, bean);
    String innerTopHeight = (innerTopFacet == null) ? "0px" : getinnerTopHeight(component, bean);
    String bottomHeight = (bottomFacet == null) ? "0px" : getBottomHeight(component, bean);
    String innerBottomHeight = (innerBottomFacet == null) ? "0px" :
      getinnerBottomHeight(component, bean);
    String leftWidth = (leftFacet == null) ? "0px" :
      (useLR ? getLeftWidth(component, bean) :
      (ltr ? getStartWidth(component, bean) : getEndWidth(component, bean)));
    String rightWidth = (rightFacet == null) ? "0px" :
      (useLR ? getRightWidth(component, bean) :
      (ltr ? getEndWidth(component, bean) : getStartWidth(component, bean)));
    String innerLeftWidth = (innerLeftFacet == null) ? "0px" :
      (useLR ? getinnerLeftWidth(component, bean) :
        (ltr ? getStartInnerWidth(component, bean) : getEndInnerWidth(component, bean)));
    String innerRightWidth = (innerRightFacet == null) ? "0px" :
      (useLR ? getinnerRightWidth(component, bean) :
        (ltr ? getEndInnerWidth(component, bean) : getStartInnerWidth(component, bean)));

    String clientId = component.getClientId(context);

    _encodePositionedFacetGroup(context, rc, bean, writer, clientId, component,
      topFacet, topHeight,
      rightFacet, rightWidth,
      bottomFacet, bottomHeight,
      leftFacet, leftWidth,
      false, useLR, isIE6, ltr);

    writer.startElement("div", null);
    writer.writeAttribute("id", _createSubId(clientId, "center"), null);
    writer.writeAttribute("style", _buildPositionedCenterCss(
      topHeight, bottomHeight, leftWidth, rightWidth, isIE6), null);
    renderStyleClass(context, rc, SkinSelectors.AF_PANEL_BORDER_POSITIONED_CENTER_STYLE_CLASS);

    _encodePositionedFacetGroup(context, rc, bean, writer, clientId, component,
      innerTopFacet, innerTopHeight,
      innerRightFacet, innerRightWidth,
      innerBottomFacet, innerBottomHeight,
      innerLeftFacet, innerLeftWidth,
      true, useLR, isIE6, ltr);

    writer.startElement("div", null);
    writer.writeAttribute("id", _createSubId(clientId, "innerCenter"), null);
    writer.writeAttribute("style", _buildPositionedCenterCss(
      innerTopHeight, innerBottomHeight, innerLeftWidth, innerRightWidth, isIE6), null);
    renderStyleClass(context, rc, SkinSelectors.AF_PANEL_BORDER_POSITIONED_INNER_CENTER_STYLE_CLASS);

    encodeAllChildren(context, component);

    writer.endElement("div");
    writer.endElement("div");
    writer.endElement("div");

    if (isIE6)
    {
      // force the resize code to run at earliest moment
      writer.startElement(XhtmlConstants.SCRIPT_ELEMENT, null);
      renderScriptDeferAttribute(context, rc);
      renderScriptTypeAttribute(context, rc);
      writer.writeText(
        new StringBuilder(clientId.length() + 58)
          .append("TrPanelBorderLayoutResizeIE6(document.getElementById('")
          .append(clientId)
          .append("'));").toString(), null);
      writer.endElement(XhtmlConstants.SCRIPT_ELEMENT);
    }
  }