public void encodeEnd(FacesContext facesContext,
UIComponent uiComponent) throws IOException {
UIOutput component = (UIOutput) uiComponent;
BoundedRangeModel model = (BoundedRangeModel) component.getValue();
if (model == null) {
LOG.warn("'null' value found! Using dummy Model instead!");
model = new DefaultBoundedRangeModel(40, 1, 0, 100);
}
String image = ResourceManagerUtil.getImageWithPath(facesContext, "image/1x1.gif");
String value1 = Integer.toString(model.getValue());
String value2 = Integer.toString(
model.getMaximum() - model.getValue());
String title = (String) component.getAttributes().get(ATTR_TIP);
if (title == null) {
title = Integer.toString(100 * model.getValue()
/ (model.getMaximum() - model.getMinimum()))
+ " %";
}
TobagoResponseWriter writer = (TobagoResponseWriter) facesContext.getResponseWriter();
writer.startElement(HtmlConstants.SPAN, null);
// TODO: use tobago standard class names
writer.writeClassAttribute("tobago-progress");
writer.writeAttribute(HtmlAttributes.TITLE, title, null);
writer.startElement(HtmlConstants.IMG, null);
writer.writeClassAttribute("tobago-progress-color1");
writer.writeAttribute(HtmlAttributes.SRC, image, null);
writer.writeAttribute(HtmlAttributes.ALT, title, null);
writer.writeAttribute(HtmlAttributes.WIDTH, value1, null);
writer.writeAttribute(HtmlAttributes.BORDER, "0", null);
writer.endElement(HtmlConstants.IMG);
writer.startElement(HtmlConstants.IMG, null);
writer.writeClassAttribute("tobago-progress-color2");
writer.writeAttribute(HtmlAttributes.SRC, image, null);
writer.writeAttribute(HtmlAttributes.ALT, title, null);
writer.writeAttribute(HtmlAttributes.WIDTH, value2, null);
writer.writeAttribute(HtmlAttributes.BORDER, "0", null);
writer.endElement(HtmlConstants.IMG);
writer.endElement(HtmlConstants.SPAN);
UIComponent facet = component.getFacet("complete");
if (model.getValue() == model.getMaximum() && facet != null
&& facet instanceof UICommand) {
UICommand command = (UICommand) facet;
HtmlRendererUtil.writeJavascript(writer, "Tobago.submitAction('" + command.getClientId(facesContext) + "');");
}