Foros de discusión

Dynamic Data List - VM Code issue

thumbnail
Andrew Jordan, modificado hace 7 años.

Dynamic Data List - VM Code issue

Junior Member Mensajes: 39 Fecha de incorporación: 2/11/15 Mensajes recientes
What am I doing wrong? I can't get the values to display.

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>
Siby Mathew, modificado hace 7 años.

RE: Dynamic Data List - VM Code issue

Expert Mensajes: 268 Fecha de incorporación: 4/03/11 Mensajes recientes
Hello Andrew,
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