boolean disabled = slider.isDisabled();
Integer min = ComponentUtils.getIntAttribute(slider, "min");
Integer max = ComponentUtils.getIntAttribute(slider, "max");
TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
Style style = new Style(facesContext, slider);
int width = -1;
int sliderWidthPerc
= getResourceManager().getThemeMeasure(facesContext, slider, SLIDER_WIDTH_PERCENT).getPixel();
if (sliderWidthPerc <= 25) {
sliderWidthPerc = 25;
}
if (sliderWidthPerc >= 75) {
sliderWidthPerc = 75;
}
int sliderWidth = 100; // fixme
int inputWidth = 50; // fixme;
if (style.getWidth() != null && style.getWidth().getPixel() >= 0) {
sliderWidth = (width * sliderWidthPerc) / 100;
inputWidth = (width * (100 - sliderWidthPerc)) / 100;
}
writer.startElement(HtmlElements.TABLE, slider);
writer.writeIdAttribute(id);
writer.writeClassAttribute(Classes.create(slider));
HtmlRendererUtils.writeDataAttributes(facesContext, writer, slider);
writer.writeStyleAttribute(style);
//writer.writeAttribute(HtmlAttributes.BORDER,"1",false);
writer.startElement(HtmlElements.TR, null);
writer.startElement(HtmlElements.TD, null);
writer.writeClassAttribute(Classes.create(slider, "min"));
Style widthStyle = new Style();
widthStyle.setWidth(Measure.valueOf(sliderWidth / 2));
writer.writeStyleAttribute(widthStyle);
writer.startElement(HtmlElements.SPAN, null);
writer.writeClassAttribute(Classes.create(slider, "min"));
writer.write(Integer.toString(min));
writer.endElement(HtmlElements.SPAN);
writer.endElement(HtmlElements.TD);
writer.startElement(HtmlElements.TD, null);
writer.writeClassAttribute(Classes.create(slider, "max"));
writer.writeStyleAttribute(widthStyle);
writer.startElement(HtmlElements.SPAN, null);
writer.writeClassAttribute(Classes.create(slider, "max"));
writer.write(Integer.toString(max));
writer.endElement(HtmlElements.SPAN);
writer.endElement(HtmlElements.TD);
// the input field starts here
writer.startElement(HtmlElements.TD, null);
writer.writeAttribute(HtmlAttributes.ROWSPAN, "2", false);
writer.writeClassAttribute(Classes.create(slider, "td"));
writer.startElement(HtmlElements.INPUT, null);
writer.writeClassAttribute(Classes.create(slider, "input"));
widthStyle.setWidth(Measure.valueOf(inputWidth));
writer.writeStyleAttribute(widthStyle);
String inputIdAndName = getIdForInputField(facesContext, slider);
writer.writeNameAttribute(inputIdAndName);
writer.writeIdAttribute(inputIdAndName);
if (currentValue != null) {
writer.writeAttribute(HtmlAttributes.VALUE, currentValue, false);
}
writer.writeAttribute(HtmlAttributes.READONLY, readonly);
writer.writeAttribute(HtmlAttributes.DISABLED, disabled);
//writer.writeAttribute(HtmlAttributes.STYLE, null, STYLE);
writer.endElement(HtmlElements.INPUT);
writer.endElement(HtmlElements.TD);
writer.endElement(HtmlElements.TR);
writer.startElement(HtmlElements.TR, null);
writer.startElement(HtmlElements.TD, null);
writer.writeAttribute(HtmlAttributes.COLSPAN, 2);
//track
writer.startElement(HtmlElements.DIV, null);
writer.writeClassAttribute(Classes.create(slider, "slider"));
writer.writeIdAttribute(getIdForSliderTrack(facesContext, slider));
// handle
writer.startElement(HtmlElements.DIV, null);
writer.writeIdAttribute(getIdForSliderHandle(facesContext, slider));
Style handleStyle = new Style();
handleStyle.setPosition(Position.RELATIVE);
handleStyle.setTop(Measure.valueOf(-6));
handleStyle.setWidth(Measure.valueOf(12));
handleStyle.setHeight(Measure.valueOf(6));
writer.writeStyleAttribute(handleStyle); // todo: why not do that via the class?
writer.startElement(HtmlElements.IMG, null);
writer.writeAttribute(HtmlAttributes.SRC, getAbsoluteImagePath(facesContext, "image/sliderTriangle.gif"), true);
writer.endElement(HtmlElements.IMG);
writer.endElement(HtmlElements.DIV);