if (!component.isRendered())
{
return;
}
Link link = (Link) component;
ResponseWriter writer = context.getResponseWriter();
if (link.isDisabled())
{
writer.startElement("span", link);
}
else
{
writer.startElement("a", link);
}
String mappingId = (String) component.getAttributes().get("mappingId");
if (mappingId == null)
{
throw new PrettyException("Mapping id was null when attempting to build URL for component: "
+ component.toString() + " <" + component.getClientId(context) + ">");
}
try
{
PrettyContext prettyContext = PrettyContext.getCurrentInstance(context);
PrettyConfig prettyConfig = prettyContext.getConfig();
UrlMapping urlMapping = prettyConfig.getMappingById(mappingId);
String href = context.getExternalContext().getRequestContextPath()
+ urlBuilder.build(urlMapping, true, urlBuilder.extractParameters(component));
if ((link.getAnchor() != null) && link.getAnchor().length() > 0)
{
href += "#" + link.getAnchor();
}
writer.writeURIAttribute("href", context.getExternalContext().encodeResourceURL(href), "href");
}
catch (PrettyException e)
{
throw new PrettyException("Failed to build URL for mapping '" + mappingId
+ "' while rendering <pretty:link> component: " + link.getClientId(context), e);
}
writeAttr(writer, "id", link.getClientId(context));
writeAttr(writer, "accesskey", link.getAccesskey());
writeAttr(writer, "charset", link.getCharset());
writeAttr(writer, "coords", link.getCoords());
writeAttr(writer, "dir", link.getDir());
writeAttr(writer, "hreflang", link.getHreflang());
writeAttr(writer, "lang", link.getLang());
writeAttr(writer, "onblur", link.getOnblur());
writeAttr(writer, "onclick", link.getOnclick());
writeAttr(writer, "ondblclick", link.getOndblclick());
writeAttr(writer, "onfocus", link.getOnfocus());
writeAttr(writer, "onkeydown", link.getOnkeydown());
writeAttr(writer, "onkeypress", link.getOnkeypress());
writeAttr(writer, "onkeyup", link.getOnkeyup());
writeAttr(writer, "onmousedown", link.getOnmousedown());
writeAttr(writer, "onmousemove", link.getOnmousemove());
writeAttr(writer, "onmouseout", link.getOnmouseout());
writeAttr(writer, "onmouseover", link.getOnmouseover());
writeAttr(writer, "onmouseup", link.getOnmouseup());
writeAttr(writer, "rel", link.getRel());
writeAttr(writer, "rev", link.getRev());
writeAttr(writer, "shape", link.getShape());
writeAttr(writer, "style", link.getStyle());
writeAttr(writer, "class", link.getStyleClass());
writeAttr(writer, "tabindex", link.getTabindex());
writeAttr(writer, "target", link.getTarget());
writeAttr(writer, "title", link.getTitle());
writeAttr(writer, "type", link.getType());
}