package net.sourceforge.fenixedu.presentationTier.renderers; import pt.ist.fenixWebFramework.renderers.components.HtmlComponent; import pt.ist.fenixWebFramework.renderers.components.HtmlText; import pt.ist.fenixWebFramework.renderers.layouts.Layout; /** * A basic presentation of an integer number. */ public class IntegerRenderer extends pt.ist.fenixWebFramework.renderers.IntegerRenderer { private String valueIfZero = "0"; public String getValueIfZero() { return valueIfZero; } public void setValueIfZero(String valueIfZero) { this.valueIfZero = valueIfZero; } @Override protected Layout getLayout(Object object, Class type) { final Layout superLayout = super.getLayout(object, type); return new Layout() { @Override public HtmlComponent createComponent(Object object, Class type) { Number number = (Number) object; if (number == null || number.doubleValue() == 0d) { return new HtmlText(getValueIfZero()); } else { return superLayout.createComponent(object, type); } } }; } }