in impl/src/main/java/org/apache/myfaces/renderkit/html/base/HtmlLinkRendererBase.java [908:1069]
protected void renderOutcomeLinkStart(FacesContext facesContext, UIOutcomeTarget output)
throws IOException
{
ResponseWriter writer = facesContext.getResponseWriter();
Map<String, List<ClientBehavior>> behaviors = null;
//calculate href
String targetHref = HtmlRendererUtils.getOutcomeTargetHref(facesContext, output);
if (HtmlRendererUtils.isDisabled(output) || targetHref == null)
{
//output.getAttributes().put(END_LINK_OUTCOME_AS_SPAN, Boolean.TRUE);
//Note one h:link cannot have a nested h:link as a child, so it is safe
//to just put this flag on FacesContext attribute map
facesContext.getAttributes().put(END_LINK_OUTCOME_AS_SPAN, Boolean.TRUE);
writer.startElement(HTML.SPAN_ELEM, output);
if (output instanceof ClientBehaviorHolder holder)
{
behaviors = holder.getClientBehaviors();
if (!behaviors.isEmpty())
{
HtmlRendererUtils.writeIdAndName(writer, output, facesContext);
}
else
{
HtmlRendererUtils.writeIdIfNecessary(writer, output, facesContext);
}
long commonPropertiesMarked = 0L;
if (isCommonPropertiesOptimizationEnabled(facesContext))
{
commonPropertiesMarked = CommonHtmlAttributesUtil.getMarkedAttributes(output);
}
if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(facesContext))
{
CommonHtmlAttributesUtil.renderEventProperties(writer,
commonPropertiesMarked, output);
CommonHtmlAttributesUtil.renderFocusBlurEventProperties(writer,
commonPropertiesMarked, output);
}
else
{
if (isCommonEventsOptimizationEnabled(facesContext))
{
long commonEventsMarked = CommonHtmlEventsUtil.getMarkedEvents(output);
CommonHtmlEventsUtil.renderBehaviorizedEventHandlers(facesContext, writer,
commonPropertiesMarked, commonEventsMarked, output, behaviors);
CommonHtmlEventsUtil.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
facesContext, writer, commonPropertiesMarked, commonEventsMarked, output, behaviors);
}
else
{
HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, output, behaviors);
HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
facesContext, writer, output, behaviors);
}
}
if (isCommonPropertiesOptimizationEnabled(facesContext))
{
CommonHtmlAttributesUtil.renderAnchorPassthroughPropertiesDisabledWithoutEvents(writer,
commonPropertiesMarked, output);
}
else
{
HtmlRendererUtils.renderHTMLAttributes(writer, output,
HTML.ANCHOR_PASSTHROUGH_ATTRIBUTES_DISABLED_WITHOUT_EVENTS);
}
}
else
{
HtmlRendererUtils.writeIdIfNecessary(writer, output, facesContext);
if (isCommonPropertiesOptimizationEnabled(facesContext))
{
CommonHtmlAttributesUtil.renderAnchorPassthroughPropertiesDisabled(writer,
CommonHtmlAttributesUtil.getMarkedAttributes(output), output);
}
else
{
HtmlRendererUtils.renderHTMLAttributes(writer, output, HTML.ANCHOR_PASSTHROUGH_ATTRIBUTES_DISABLED);
}
}
Object value = output.getValue();
if(value != null)
{
writer.writeText(value.toString(), ComponentAttrs.VALUE_ATTR);
}
}
else
{
//write anchor
writer.startElement(HTML.ANCHOR_ELEM, output);
writer.writeURIAttribute(HTML.HREF_ATTR, targetHref, null);
if (output instanceof ClientBehaviorHolder holder)
{
behaviors = holder.getClientBehaviors();
if (!behaviors.isEmpty())
{
HtmlRendererUtils.writeIdAndName(writer, output, facesContext);
}
else
{
HtmlRendererUtils.writeIdAndNameIfNecessary(writer, output, facesContext);
}
long commonPropertiesMarked = 0L;
if (isCommonPropertiesOptimizationEnabled(facesContext))
{
commonPropertiesMarked = CommonHtmlAttributesUtil.getMarkedAttributes(output);
}
if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(facesContext))
{
CommonHtmlAttributesUtil.renderEventProperties(writer,
commonPropertiesMarked, output);
CommonHtmlAttributesUtil.renderFocusBlurEventProperties(writer,
commonPropertiesMarked, output);
}
else
{
if (isCommonEventsOptimizationEnabled(facesContext))
{
long commonEventsMarked = CommonHtmlEventsUtil.getMarkedEvents(output);
CommonHtmlEventsUtil.renderBehaviorizedEventHandlers(facesContext, writer,
commonPropertiesMarked, commonEventsMarked, output, behaviors);
CommonHtmlEventsUtil.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
facesContext, writer, commonPropertiesMarked, commonEventsMarked, output, behaviors);
}
else
{
HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, output, behaviors);
HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
facesContext, writer, output, behaviors);
}
}
if (isCommonPropertiesOptimizationEnabled(facesContext))
{
CommonHtmlAttributesUtil.renderAnchorPassthroughPropertiesWithoutEvents(writer,
commonPropertiesMarked, output);
}
else
{
HtmlRendererUtils.renderHTMLAttributes(writer, output,
HTML.ANCHOR_PASSTHROUGH_ATTRIBUTES_WITHOUT_EVENTS);
}
}
else
{
HtmlRendererUtils.writeIdAndNameIfNecessary(writer, output, facesContext);
if (isCommonPropertiesOptimizationEnabled(facesContext))
{
CommonHtmlAttributesUtil.renderAnchorPassthroughProperties(writer,
CommonHtmlAttributesUtil.getMarkedAttributes(output), output);
}
else
{
HtmlRendererUtils.renderHTMLAttributes(writer, output,
HTML.ANCHOR_PASSTHROUGH_ATTRIBUTES);
}
}
writer.flush();
}
}