Skip to content

Instantly share code, notes, and snippets.

@christoph-frick
Created June 27, 2014 07:41
Show Gist options
  • Save christoph-frick/28c5c4f61d0e8a5baecb to your computer and use it in GitHub Desktop.
Save christoph-frick/28c5c4f61d0e8a5baecb to your computer and use it in GitHub Desktop.
Vaadin Multiline Field (List<String> in TextArea)
import com.vaadin.ui.Component
import com.vaadin.ui.CustomField
import com.vaadin.ui.TextArea
class MultiLineField extends CustomField<List<String>> {
private TextArea textArea = new TextArea()
MultiLineField() {
super()
}
MultiLineField(String caption) {
this()
setCaption(caption)
}
@Override
protected Component initContent() {
return textArea
}
@Override
Class<? extends List<String>> getType() {
return List
}
@Override
protected List<String> getInternalValue() {
return textArea.value.readLines()
}
protected void setInternalValue(List<String> newValue) {
super.setInternalValue(newValue)
if (newValue!=null) {
textArea.value = newValue.join("\n")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment