1
我有一個包含幾段信息(純文本)的txt文件,我將如何在textarea中顯示此文件。到目前爲止,我試過在vaadin佈局中顯示txt文件
FileResource file = new FileResource(new File("/path/to/file");
TextArea text = new TextArea();
text.setData(file);
這不起作用
我有一個包含幾段信息(純文本)的txt文件,我將如何在textarea中顯示此文件。到目前爲止,我試過在vaadin佈局中顯示txt文件
FileResource file = new FileResource(new File("/path/to/file");
TextArea text = new TextArea();
text.setData(file);
這不起作用
不要使用setData()
方法,而是在setValue(....)
方法。請參閱Book of Vaadin和API doc中的TextArea
主題。
這需要一個字符串,所以您必須從文件中讀取字符串中的文本,然後在TextArea上使用setValue()
。
set/getData()方法允許您保存Vaadin沒有使用的「私有」數據。