You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Steve Lowery <sl...@gatessolutions.com> on 2012/08/16 16:10:58 UTC

form inputs to Labels

We have forms throughout our application that can be toggled from read-only
to editable.  The wicket framework will disable the form components which
is great, but we'd rather have it display just the texts in a label.  We
can subclass TextField, TextArea, DropDownChoice, etc and override the
onComponentTag() and onComponentTagBody() methods where applicable, but was
wondering if anyone had a more elegant solution or wicket had something out
of the box that would turn FormComponents into Labels.

Here's example for a TextField we could do by subclassing TextField and
overriding onComponentTag:

@Override
protected void onComponentTag(ComponentTag tag) {
if (!isEnabledInHierarchy()) {
tag.setName("span");
tag.remove("type");
tag.remove("disabled");
tag.remove("name");
tag.remove("value");
tag.setType(XmlTag.TagType.OPEN);
}
}