Example usage for org.apache.wicket.markup.html.image.resource LocalizedImageResource setSrcAttribute

List of usage examples for org.apache.wicket.markup.html.image.resource LocalizedImageResource setSrcAttribute

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.image.resource LocalizedImageResource setSrcAttribute.

Prototype

public final void setSrcAttribute(final ComponentTag tag) 

Source Link

Usage

From source file:org.dcm4chee.web.war.tc.imageview.TCWadoImage.java

License:LGPL

/**
 * @see org.apache.wicket.Component#onComponentTag(ComponentTag)
 *//* www . j av  a 2s  . com*/
@Override
protected void onComponentTag(final ComponentTag tag) {
    checkComponentTag(tag, "img");

    super.onComponentTag(tag);

    //set src-attribute
    if (isValid(getModel())) {
        tag.put("src", getWadoUrl(requestedSize));
    } else {
        LocalizedImageResource emptyImage = getEmptyImage();
        if (emptyImage != null) {
            emptyImage.setSrcAttribute(tag);
        }
    }

    //set width attribute, if available
    if (renderedSize != null) {
        int width = renderedSize.getWidth();
        int height = renderedSize.getHeight();
        if (width > 0) {
            tag.put("width", width);
        }
        if (height > 0) {
            tag.put("height", height);
        }
    }
}