Dynamic Data List not listing data - Velocity Liferay

222 Views Asked by At

What am I doing wrong? I can't get the values to display within a Liferay Dynamic Data List portlet. The following is the template code. Currently nothing is displaying after the header. However, I see the closing table tag in the rendered HTML.

#set ($ddlRecordService = $serviceLocator.findService('com.liferay.portlet.dynamicdatalists.service.DDLRecordLocalService'))
#set ($recordSetId = $getterUtil.getLong($reserved_record_set_id.data))
#set ($records = $ddlRecordService.getRecords($recordSetId))

<table class="table table-striped">
<caption>Audio files listing of FDR speeches</caption>
<thead>
   <tr>
        <th>Date</th>
        <th>Description</th>
        <th>Tape information</th>
    </tr>
  </thead>
 <tbody>
 #foreach($record in $records) 

        #set ($audioDate = $record.getField("audioDate").getValue())
        #set ($audioDesc = $record.getField("audioDesc").getValue())
        #set ($audioLink = $record.getField("audioLink").getValue())
     <tr>
        <td>$audioDate</td>
        <td>$audioDesc</td>
        <td>$audioLink</td>
    </tr>
  #end
</tbody>
</table>
1

There are 1 best solutions below

0
On

Either your $records is empty or it is not added to the velocity context. you can add it to the context using:

VelocityContext context = new VelocityContext();

context.put("records", your_records_list);