public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
UILink link = (UILink) component;
String clientId = link.getClientId(facesContext);
CommandRendererHelper helper = new CommandRendererHelper(facesContext, link, CommandRendererHelper.Tag.ANCHOR);
String href = helper.getHref();
TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
LabelWithAccessKey label = new LabelWithAccessKey(link);
if (helper.isDisabled()) {
writer.startElement(HtmlElements.SPAN, link);
} else {
writer.startElement(HtmlElements.A, link);
writer.writeAttribute(HtmlAttributes.HREF, href, true);
if (helper.getOnclick() != null) {
writer.writeAttribute(HtmlAttributes.ONCLICK, helper.getOnclick(), true);
}
if (helper.getTarget() != null) {
writer.writeAttribute(HtmlAttributes.TARGET, helper.getTarget(), true);
}
Integer tabIndex = null;
if (link instanceof UILink) {
tabIndex = ((UILink) link).getTabIndex();
} else {
Deprecation.LOG.warn("LinkRenderer should only render UILink but got " + link.getClass().getName()
+ " id=" + link.getClientId(facesContext));
}
if (tabIndex != null) {
writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
}
}
Style style = new Style(facesContext, link);
writer.writeStyleAttribute(style);
HtmlRendererUtils.renderDojoDndItem(component, writer, true);
writer.writeClassAttribute(Classes.create(link));
writer.writeIdAttribute(clientId);
writer.writeNameAttribute(clientId);
HtmlRendererUtils.renderTip(link, writer);
writer.flush();
// image
String image = link.getImage();
if (image != null) {
if (ResourceManagerUtils.isAbsoluteResource(image)) {
// absolute Path to image : nothing to do
} else {
image = getImageWithPath(facesContext, image, helper.isDisabled());
}
writer.startElement(HtmlElements.IMG, link);
writer.writeAttribute(HtmlAttributes.SRC, image, true);
writer.writeAttribute(HtmlAttributes.BORDER, 0); // TODO: is border=0 setting via style possible?
String tip = link.getTip();