private void _writeItemLink()

in trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/NavigationPaneRenderer.java [653:814]


  private void _writeItemLink(
    FacesContext        context,
    RenderingContext    rc,
    ResponseWriter      rw,
    Map<String, Object> itemData,
    boolean             isDisabled
    ) throws IOException
  {

    UIXCommand commandChild = (UIXCommand)itemData.get("component");
    if (isDisabled)
    {
      _renderText(rw, itemData);
      _renderCommandChildren(context, commandChild);
      return;
    }

    String destination = toResourceUri(context, (itemData.get("destination")));
    boolean immediate = false;
    boolean partialSubmit = false;
    if (destination == null)
    {
      immediate = getBooleanFromProperty(itemData.get("immediate"));
      partialSubmit = getBooleanFromProperty(itemData.get("partialSubmit"));
      if (partialSubmit)
      {
        AutoSubmitUtils.writeDependencies(context, rc);
      }
      String clientId = commandChild.getClientId(context);
      // Make sure we don't have anything to save
      assert(rc.getCurrentClientId() == null);
      rc.setCurrentClientId(clientId);

      // Find the params up front, and save them off -
      // getOnClick() doesn't have access to the UIComponent
      String extraParams = AutoSubmitUtils.getParameters(commandChild);
      rc.getProperties().put(_EXTRA_SUBMIT_PARAMS_KEY, extraParams);
    }

    boolean isActive = getBooleanFromProperty(itemData.get("isActive"));
    boolean isDesktop = (rc.getAgent().getType().equals(Agent.TYPE_DESKTOP));

    boolean nonJavaScriptSubmit = (!supportsScripting(rc))
                                             && (destination == null);

    // For non-javascript browsers, we need to render a submit element
    // instead of an anchor tag if the anchor tag doesn't have a destination

    if (nonJavaScriptSubmit)
    {

      rw.startElement("input", commandChild);

      rw.writeAttribute("type", "submit", null);
      rw.writeAttribute("value", toString(itemData.get("text")), "text");

      String clientId = getClientId(context, commandChild);
      rw.writeAttribute("id", clientId, "id");



      // For Non-JavaScript browsers, encode the name attribute with the
      // parameter name and value thus it would enable the browsers to
      // include the name of this element in its payLoad if it submits the
      // page.

      rw.writeAttribute("name", XhtmlUtils.getEncodedParameter
                                  (XhtmlConstants.SOURCE_PARAM)
                                   + clientId, null);
      renderStyleClass(context, rc,
                  SkinSelectors.AF_COMMAND_BUTTON_STYLE_CLASS);
      String linkConverter =
             "border:none;background:inherit;text-decoration:underline;";

      // Few mobile browsers couldn't apply css property for active elements
      // so making it inline
      if (isActive && !isDesktop)
      {
        linkConverter = linkConverter + "font-weight: bold;";
      }

      writeInlineStyles(rw, null,linkConverter);

    }
    else
    {
      rw.startElement("a", commandChild); // linkElement

      // Few mobile browsers couldn't apply css property for active elements
      // so making it inline
      if (isActive && !isDesktop)
      {
        writeInlineStyles(rw, null,"font-weight: bold;");
      }
      _renderCommandChildId(context, commandChild);

      if (destination == null)
      {
        rw.writeURIAttribute("href", "#", null); // required for IE to support ":hover" styles
      }
      else
      {
        renderEncodedActionURI(context, "href", destination);
        String targetFrame = toString(itemData.get("targetFrame"));
        if ( (targetFrame != null) && !Boolean.FALSE.equals(
          rc.getAgent().getCapabilities().get(TrinidadAgent.CAP_TARGET)) )
        {
          rw.writeAttribute("target", targetFrame, null);
        }
      }



      // Cannot use super.renderEventHandlers(context, bean); because the wrong
      // property keys would be in use so must do it this way:
      // Also render the events only if the browser supports JavaScript
      if (supportsScripting(rc))
      {
        _writeOnclickProperty(
          rc,
          rw,
          commandChild,
          (destination == null),
          immediate,
          partialSubmit); // special for actions!
        _writeCommandChildProperty(rw, commandChild, "ondblclick");
        _writeCommandChildProperty(rw, commandChild, "onkeydown");
        _writeCommandChildProperty(rw, commandChild, "onkeyup");
        _writeCommandChildProperty(rw, commandChild, "onkeypress");
        _writeCommandChildProperty(rw, commandChild, "onmousedown");
        _writeCommandChildProperty(rw, commandChild, "onmousemove");
        _writeCommandChildProperty(rw, commandChild, "onmouseout");
        _writeCommandChildProperty(rw, commandChild, "onmouseover");
        _writeCommandChildProperty(rw, commandChild, "onmouseup");
      }
    }

    String accessKey = toString(itemData.get("accessKey"));
    if ( !isDisabled && (accessKey != null) )
    {
      rw.writeAttribute("accessKey", accessKey, null);
    }

    // In the case of HTML basic browsers, we render an input element. Hence,
    // we cannot render any children, so skip calling _renderCommandChildren
    if (nonJavaScriptSubmit)
    {
      rw.endElement("input");
    }
    else
    {
      _renderText(rw, itemData);
      _renderCommandChildren(context, commandChild);
      rw.endElement("a"); // linkElement
    }

    if (destination == null)
    {
      rc.setCurrentClientId(null);
      rc.getProperties().remove(_EXTRA_SUBMIT_PARAMS_KEY);
    }
  }