Skip to content

Instantly share code, notes, and snippets.

@gabrielke
Forked from marcellustavares/user_template.vm
Created May 29, 2012 21:48
Show Gist options
  • Save gabrielke/2830993 to your computer and use it in GitHub Desktop.
Save gabrielke/2830993 to your computer and use it in GitHub Desktop.
User List Template
## Get the reference of DDL Record Service via serviceLocator, which is automatically set in the context
#set ($ddlRecordService = $serviceLocator.findService('com.liferay.portlet.dynamicdatalists.service.DDLRecordLocalService'))
## $reserved_record_set_id is also an object set in the context and it has the value of the list id configured for the portlet instance
#set ($recordSetId = $getterUtil.getInteger($reserved_record_set_id.data, 0))
## call to the retrieve all records of the list
#set ($records = $ddlRecordService.getRecords($recordSetId))
#foreach($record in $records)
## each record has a collection of fields (name and avatar in our case)
#set ($fields = $record.getFields())
#set ($nameField = $fields.get("name"))
#set ($avatarField = $fields.get("avatar"))
## the avatar is a file upload field and its value holds a JSON object
## jsonFactoryUtil help us to convert string value into a JSON object
#set ($avatarJSONObject = $jsonFactoryUtil.createJSONObject($avatarField.value))
#set ($fileName = $avatarField.getName())
#set ($className = $avatarJSONObject.getString("className"))
#set ($classPK = $avatarJSONObject.getString("classPK"))
<div style="padding-top: 10px;">
<img height="100" src='/documents/ddm/${className}/${classPK}/${fileName}' width="100" />
<span style="padding-left: 5px;">
$nameField.getValue()
<span>
</div>
#end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment