留言板
Dynamic Data List - VM Code issue
What am I doing wrong? I can't get the values to display.
I've updated the code since last night:
Yesterday's code:
I've updated the code since last night:
#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>
Yesterday's code:
<table class="table table-striped">
<caption>Audio files listing of FDR speeches</caption>
<thead>
<tr>
#set ($ddlRecordService = $serviceLocator.findService('com.liferay.portlet.dynamicdatalists.service.DDLRecordLocalService'))
#set ($recordSetId = $getterUtil.getInteger($reserved_record_set_id.data, 0))
#set ($records = $ddlRecordService.getRecords($recordSetId))
#foreach($record in $records)
#set ($fields = $record.getFields())
#set ($dateField = $fields.get("audioDate"))
#set ($descriptionField = $fields.get("audioDescription"))
#set ($audioInfoField = $fields.get("audioInfo"))
<th>Date</th>
<th>Description</th>
<th>Tape information</th>
</tr>
</thead>
<tbody>
<tr>
<td>$dateField.getValue()
</td>
<td>$descriptionField.getValue()
</td>
<td>$audioInfoField.getValue()</td>
</tr>
#end
</tbody>
</table>
Hello Andrew,
Have you already removed servicelocator from the restricted variable list in portal-ext.properties?
If you still have issues, try printing the variables in order to find the place where you get an error.
Thanks,
Siby Mathew
Have you already removed servicelocator from the restricted variable list in portal-ext.properties?
#
# Set a comma delimited list of variables the Velocity engine cannot
# have access to. This will affect Dynamic Data List templates, Journal
# templates, and Portlet Display templates.
#
velocity.engine.restricted.variables=serviceLocator
If you still have issues, try printing the variables in order to find the place where you get an error.
Thanks,
Siby Mathew