@Override
public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
if (!component.isRendered())
return;
DynamicImage dynamicImage = (DynamicImage) component;
ValueExpression dataExpression = dynamicImage.getDataExpression();
ELContext elContext = FacesContext.getCurrentInstance().getELContext();
Object data = dataExpression.getValue(elContext);
if (data == null)
return;
ImageDataModel model = Rendering.getDataModel(data);
String extension = DIMG_EXTENSION;
if (dynamicImage.getImageType() != null)
extension = dynamicImage.getImageType().getExtension();
ResponseWriter writer = facesContext.getResponseWriter();
Rendering.startWriteIMG(writer, facesContext, dynamicImage, extension, model, null);
writeAttribute(writer, "style", dynamicImage.getStyle());
writeAttribute(writer, "class", Styles.mergeClassNames(dynamicImage.getStyleClass(), (String) dynamicImage.getAttributes().get(DEFAULT_STYLE_ATTR)));
writeAttribute(writer, "width", dynamicImage.getWidth(), -1);
writeAttribute(writer, "height", dynamicImage.getHeight(), -1);
writeAttribute(writer, "alt", dynamicImage.getAlt());
Rendering.writeStandardEvents(writer, dynamicImage);
String mapId = dynamicImage.getMapId();
if (mapId != null)
writer.writeAttribute("usemap", "#" + mapId, null);
Rendering.encodeInitComponentCall(facesContext, dynamicImage, true);
writer.endElement("img");
if (dynamicImage.getMap() != null) {
Rendering.writeNewLine(writer);
writer.write(dynamicImage.getMap());
}
}