@Override protected HtmlComponent renderComponent(Layout layout, Object object, Class type) { String value = (String) object; MetaSlot slot = (MetaSlot) getInputContext().getMetaObject(); HtmlMenu menu = (HtmlMenu) super.renderComponent(layout, object, type); HtmlMenuOption otherOption = createOtherOption(menu); HtmlHiddenField field = new HtmlHiddenField(); HtmlTextInput other = new HtmlTextInput(); other.setSize(getOtherSize()); boolean otherSelected = true; for (HtmlMenuEntry entry : menu.getEntries()) { if (entry.isSelected()) { other.setStyle("display: none;"); otherSelected = false; break; } } if (otherSelected) { otherOption.setSelected(true); other.setValue(value); } field.setValue(value); field.bind(slot); field.setController(new CopyController(menu, other)); menu.setTargetSlot(null); menu.setName(getLocalName(slot, "menu")); other.setName(getLocalName(slot, "other")); HtmlContainer container = new HtmlBlockContainer(); container.addChild(createSwitchScript(field, menu, other)); container.addChild(field); container.addChild(menu); container.addChild(other); return container; }
@Override public HtmlComponent createComponent(Object object, Class type) { HtmlComponent component = super.createComponent(object, type); HtmlContainer container = new HtmlBlockContainer(); container.addChild(component); container.addChild(this.hiddenValues); HtmlActionLink link = new HtmlActionLink(); link.setName(getInputContext().getMetaObject().getKey().toString() + "/add"); link.setText(RenderUtils.getResourceString("renderers.list.management.add")); link.setController( new FollowDestinationController((MetaSlot) getInputContext().getMetaObject())); container.addChild(link); return container; }
@Override public void applyStyle(HtmlComponent component) { HtmlContainer container = (HtmlContainer) component; super.applyStyle(container.getChildren().get(0)); }