public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
UIButton button = (UIButton) component;
String clientId = button.getClientId(facesContext);
CommandRendererHelper helper = new CommandRendererHelper(facesContext, button, CommandRendererHelper.Tag.BUTTON);
TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
LabelWithAccessKey label = new LabelWithAccessKey(button);
writer.startElement(HtmlElements.BUTTON, button);
writer.writeAttribute(HtmlAttributes.TYPE, HtmlButtonTypes.BUTTON, false);
writer.writeNameAttribute(clientId);
writer.writeIdAttribute(clientId);
HtmlRendererUtils.renderTip(button, writer);
writer.writeAttribute(HtmlAttributes.DISABLED, helper.isDisabled());
Integer tabIndex = button.getTabIndex();
if (tabIndex != null) {
writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
}
if (helper.getOnclick() != null) {
writer.writeAttribute(HtmlAttributes.ONCLICK, helper.getOnclick(), true);
}
Style style = new Style(facesContext, button);
writer.writeStyleAttribute(style);
HtmlRendererUtils.renderDojoDndItem(component, writer, true);
writer.writeClassAttribute(Classes.create(button));
if (((UIButton) component).isDefaultCommand()) {
final AbstractUIForm form = ComponentUtils.findAncestor(component, AbstractUIForm.class);
writer.writeAttribute(DataAttributes.DEFAULT, form.getClientId(facesContext), false);
}
writer.flush(); // force closing the start tag
String image = (String) button.getAttributes().get(Attributes.IMAGE);
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, null);
writer.writeAttribute(HtmlAttributes.SRC, image, true);
String tip = button.getTip();
writer.writeAttribute(HtmlAttributes.ALT, tip != null ? tip : "", true);