I am using Java Wicket to create a table. I want to write a cell made of multiple lines; each line within the cell represents a data item.
List<EntityClassModel> classesList = classService.getClassesByNotificationId(nitem.getModelObject().getId());
nitem.add(new Label("classnamelab", getClassNames(classesList)));
However, when I concatenate the lines, inside getClassNames
, using classNames.append("<br>");
the page displays Latin 101<br>Latin 103
. From Chrome I Save As the page and opened it in Notepad++. It showed <td class="laclasses">Latin 101<br>Latin 103</td>
.
I also tried the code classNames.append("<br>");
. It was displayed in the cell as Latin 101<br>Latin 103
, wich is worse.
Using the saved files, I copied a row and changed the text to <td class="laclasses">Angle 101<br>Bracket 103</td>
. That showed the data Angle 101
and Bracket 103
on two lines within the cell, which is what I want. Developer Tools showed the coding on five lines.
<td class="laclasses">
"Angle 101"
<br>
"Bracket 103"
</td>
The style sheet includes the block
td.laclasses
{
width: 140px;
padding-right: 1em;
text-align: left;
white-space: pre;
}
Is there a simple way for Wicket to encode the multiple string so that they show as multiple lines within a cell?
您应该使用org.apache.wicket.markup.html.basic.MultiLineLabel
。
The MultiLineLabel
worked. I had to change the style as the data was inside a <p>...</p>
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.