package pt.ist.fenixWebFramework.renderers; import pt.ist.fenixWebFramework.renderers.components.HtmlComponent; import pt.ist.fenixWebFramework.renderers.components.HtmlMenu; import pt.ist.fenixWebFramework.renderers.components.HtmlMenuOption; import pt.ist.fenixWebFramework.renderers.layouts.Layout; import pt.ist.fenixWebFramework.renderers.model.MetaSlotKey; import pt.ist.fenixWebFramework.renderers.utils.RenderUtils; /** * This renderer provides an alternative way of doing the input of * a boolean value. This renderer presents an html menu with two * options: one for the true value, and other for the * false value. * *

* The options text is retrieved from the resources using the keys * TRUE and FALSE. * *

* Example: * * * @author cfgi */ public class BooleanMenuInputRenderer extends InputRenderer { @Override protected Layout getLayout(Object object, Class type) { return new Layout() { @Override public HtmlComponent createComponent(Object object, Class type) { HtmlMenu menu = new HtmlMenu(); HtmlMenuOption trueOption = menu.createOption(RenderUtils.getResourceString("TRUE")); HtmlMenuOption falseOption = menu.createOption(RenderUtils.getResourceString("FALSE")); trueOption.setValue("true"); falseOption.setValue("false"); if (object != null) { (((Boolean) object) ? trueOption : falseOption).setSelected(true); } menu.setTargetSlot((MetaSlotKey) getInputContext().getMetaObject().getKey()); return menu; } }; } }