/**
   * @param facesContext
   * @param uiComponent
   * @throws IOException
   */
  public void encodeBegin(FacesContext facesContext, UIComponent uiComponent) throws IOException {
    if (facesContext == null || uiComponent == null) {
      throw new NullPointerException("facesContext or uiComponent is null");
    }

    UIOutput output = (UIOutput) uiComponent;
    String linkVal = getValue(facesContext, uiComponent);

    if (!output.isRendered()) return;

    ResponseWriter writer = facesContext.getResponseWriter();

    if (writer == null) {
      throw new NullPointerException("ResponseWriter is null");
    }

    if (!checkDisabled(uiComponent)) {
      writer.startElement("a", uiComponent);
    } else {
      writer.startElement("span", uiComponent);
    }
    writer.writeAttribute("id", uiComponent.getClientId(facesContext), "id");

    if (null == linkVal || 0 == linkVal.length()) {
      linkVal = "";
    }

    clientId = output.getClientId(facesContext);

    linkVal = appendParameters(facesContext, uiComponent, linkVal);

    if (!checkDisabled(uiComponent)) {
      writer.writeURIAttribute(
          "href", facesContext.getExternalContext().encodeResourceURL(linkVal), "href");
    }

    // ICE-2169
    PassThruAttributeWriter.renderHtmlAttributes(writer, uiComponent, passThruAttributes);
    Boolean visibleAttribute = (Boolean) uiComponent.getAttributes().get("visible");
    boolean isVisible = visibleAttribute == null ? true : visibleAttribute.booleanValue();
    String style = (String) uiComponent.getAttributes().get(HTML.STYLE_ATTR);
    if (!isVisible) {
      if (style == null) {
        style = "";
      } else if (style.trim().length() == 0 || style.trim().endsWith(";")) {
        // nothing
      } else {
        style += ";";
      }
      style += "display:none;";
    }
    if (style != null) writer.writeAttribute(HTML.STYLE_ATTR, style, HTML.STYLE_ATTR);

    String styleClass = (String) output.getAttributes().get("styleClass");
    if (styleClass != null) writer.writeAttribute("class", styleClass, "styleClass");

    writer.flush();
  }
  protected void renderHtmlAttributes(
      FacesContext facesContext, ResponseWriter writer, UIComponent uiComponent)
      throws IOException {
    PassThruAttributeWriter.renderHtmlAttributes(writer, uiComponent, passThruAttributes);

    // fix for ICE-2514
    String app = (String) uiComponent.getAttributes().get(HTML.ONMOUSEDOWN_ATTR);
    String rend = ONMOUSEDOWN_FOCUS;
    String combined = DomBasicRenderer.combinedPassThru(app, rend);
    writer.writeAttribute(HTML.ONMOUSEDOWN_ATTR, combined, HTML.ONMOUSEDOWN_ATTR);
  }