@Override protected HtmlComponent createTextField(Object object, Class type) { Person person = (Person) object; String username = (person != null) ? person.getUsername() : null; final HtmlComponent container = super.createTextField(username, type); final HtmlFormComponent formComponent = (HtmlFormComponent) container.getChild( new Predicate<HtmlComponent>() { @Override public boolean apply(HtmlComponent input) { return input instanceof HtmlFormComponent; } }); formComponent.setConverter(new PersonUsernameConverter()); return formComponent; }
@Override public HtmlComponent render(Object object, Class type) { HtmlInlineContainer container = new HtmlInlineContainer(); String prefix = HtmlComponent.getValidIdOrName( ((MetaSlot) getInputContext().getMetaObject()) .getKey() .toString() .replaceAll("\\.", "_") .replaceAll("\\:", "_")); HtmlHiddenField hidden = new HtmlHiddenField(prefix + HIDDEN_NAME, ""); HtmlMenu menu = (HtmlMenu) super.render(object, type); menu.setOnChange("this.form." + prefix + HIDDEN_NAME + ".value='true';this.form.submit();"); menu.setController(new PostBackController(hidden, getDestination())); container.addChild(hidden); container.addChild(menu); return container; }