Column contents truncated

Hi,

I’ve got a table with a column that has varying contents. In most cases, the contents are small pieces of text, but occasionally it can be a long line or even multiple lines. (The table is viewing a log file contents and log lines may contain simple messages as well as big Java stack traces.)

I implemented this as a generated column. (Source code below) As you can see, a TextField is used for entries without line breaks, otherwise a TextArea. That mostly works, with one exception: If a line has no line breaks (in other words: If a TextField is used) and the line exceeds a certain size (about 25 characters), then the rest of the line is truncated.

Any explanations or suggestions?

Thanks,

Jochen


			public Component generateCell(Table pTable, Object pItemId, Object pColumnId) {
				@SuppressWarnings("unchecked")
				final String message = ((BeanItem<LogFileEntry>) pTable.getItem(pItemId)).getBean().getMessage();
				if (message == null  ||  message.indexOf('\n') == -1) {
					final TextField field = new TextField();
					field.setValue(message);
					field.setReadOnly(true);
					return field;
				} else {
					final TextArea field = new TextArea();
					field.setValue(message);
					field.setReadOnly(true);
					setRowsAndColumns(field, message); // Calculates textarea size, 5 <= columns <= 80
					return field;
				}
			}

The generated HTML input element has the default width, and the element won’t expand to fit the content automatically. You need to set the width of the TextField manually to a width that can show the whole value (use something like field.setWidth(message.length * 0.6, UNITS_EM)).