public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
AbstractUILink link = (AbstractUILink) 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 = link.getTabIndex();
if (tabIndex != null) {
writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
}
}
HtmlRendererUtils.writeDataAttributes(facesContext, writer, link);
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.writeClassAttribute(Classes.create(link, "image"));
writer.writeAttribute(HtmlAttributes.SRC, image, true);
writer.writeAttribute(HtmlAttributes.BORDER, 0); // TODO: is border=0 setting via style possible?