/**
 * Licensed under the MICE s.r.l.
 * End User License Agreement
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.micegroup.it/voila/license.html
 */
package it.mice.voila.runtime.displaytag.basedec;

import javax.servlet.http.HttpServletRequest;

/**
 * Display Column Decorator per la trasformazione dei campi valori con 2 cifre decimali. 
 */
public class StandardImageDecorator extends ValueDecorator {
    private static final String URL_PREFIX = "/images/";

	public StandardImageDecorator() {
        super();
    }

    public String decorate(Object value) {
    	if (value == null) {
    		return "";
    	}
    	HttpServletRequest request = (HttpServletRequest)getPageContext().getRequest();
    	StringBuffer output = new StringBuffer();
    	//<img src="<c:url value="/images/${customerTable.iconImageName}" />"/>
    	output.append("<img src='");
    	output.append(request.getContextPath() + URL_PREFIX + value);
    	output.append("' class='iconImage' onError='hideIconImageBroken(this);'/>");
   	
        return output.toString();
    }
}
