Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-34792

DDL - Display Template - File Upload field doesn't display image in dynamic data list display portlet

    Details

    • Type: Regression Bug
    • Status: Closed
    • Resolution: Won't Fix
    • Affects Version/s: 6.2.0 CE M5
    • Fix Version/s: 6.2.0 CE M5
    • Labels:
      None
    • Environment:
      Tomcat 7.0.34 + MySQL 5. Portal 6.2.x GIT ID: d2be211bdf40330cfb354d66d01a98e4279698d2.
    • Fix Priority:
      5

      Description

      This doesn't show up in ee-6.1.x. I used the same template, and the image showed up fine in ee-6.1.x.

      I also tried this in FTL and it didn't work with that either.

      Steps to reproduce:

      1. Add a data definition with a file upload and change the field name to "file_upload"
      2. Add a display template to the data definition.
        • Use velocity and enter the following (a shortened version of the template from this blog post)
        • #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 ($file_uploadField = $fields.get("file_upload"))
          
          #set ($file_uploadJSONObject = $jsonFactoryUtil.createJSONObject($file_uploadField.value))
           
          #set ($fileName = $file_uploadField.getName())
          #set ($className = $file_uploadJSONObject.getString("className"))
          #set ($classPK = $file_uploadJSONObject.getString("classPK"))
          
          <div>
          <img height="100" src='/documents/ddm/${className}/${classPK}/${fileName}' width="100" />
          </div>
          
          #end
      3. Add a list that uses the created data definition
      4. Add a record to the definition
      5. Add a dynamic data lists portlet and select the list and select the template created in step 2
        • The image will not show up in the portlet. On a previous try, I managed to get a stacktrace in the console, but I now can't reproduce that stacktrace.

      These are the things I printed out and what ended up showing up.

      $fields = com.liferay.portlet.dynamicdatamapping.storage.Fields@45f44d94
      $file_uploadField = com.liferay.portlet.dynamicdatamapping.storage.Field@17f22e34
      $file_uploadJSONObject = {"name":"Document_2.png","path":"ddm/com.liferay.portlet.dynamicdatalists.model.DDLRecord/10426/1.0/file_upload","className":"com.liferay.portlet.dynamicdatalists.model.DDLRecord","classPK":"10426"}
      $fileName = file_upload
      $className = com.liferay.portlet.dynamicdatalists.model.DDLRecord
      $classPK = [a five digit number]

      Expected result:
      The image will show up in the portlet.

      Actual result:
      The image does not show up.

        Attachments

          Activity

            People

            Assignee:
            brian.chiu Brian Chiu (Inactive)
            Reporter:
            brian.chiu Brian Chiu (Inactive)
            Participants of an Issue:
            Recent user:
            Esther Sanz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              7 years, 25 weeks, 2 days ago

                Packages

                Version Package
                6.2.0 CE M5