Created
June 27, 2014 07:41
-
-
Save christoph-frick/28c5c4f61d0e8a5baecb to your computer and use it in GitHub Desktop.
Vaadin Multiline Field (List<String> in TextArea)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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