我有一个表,需要呈现它的行和列。我能够正确地看到CRXDE上的数据,但我无法在HTL上呈现它。
下面是java类:
public class Table {
@ChildResource
private List<TableRow> tableRowList;
}
public class TableRow
{
@ValueMapValue
private String key;
@ChildResource
private List<TableColumn> tableColumnList;
}
public class TableColumn
{
@ValueMapValue
private String colValue;
}以下是简化的HTL:
<sly data-sly-use.model="models.Table"
<table class="table">
<tbody>
<sly data-sly-list="${model.tableRowList}">
<tr>
<th>${item.key @context='html'}</th>
<th data-sly-repeat.colValue="${item.tableColumnList}">${colValue @context='html'}</th>
</tr>
</sly>
</tbody>
</table>
</sly>key 被正确地呈现,但不是每一行的列列表。当我检查CRXDE时,数据按预期存储。

知道出了什么问题吗?
发布于 2022-11-08 07:16:00
您需要在colValue上显式调用TableColumn属性,我重构了HTL/Sightly片段,以更好地显示哪个变量是哪种类型/类:
<table class="table" data-sly-use.table="models.Table">
<tbody>
<tr data-sly-repeat.tableRow="${table.tableRowList}">
<th>${tableRow.key @context='html'}</th>
<th data-sly-repeat.tableColumn="${tableRow.tableColumnList}">${tableColumn.colValue @context='html'}</th>
</tr>
</tbody>
</table>PS:我强烈建议您不要访问这样的私有属性,而是通过getter公开它们。
https://stackoverflow.com/questions/74322341
复制相似问题