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

Liferay Forms: url not populated in JSON when a document is selected after being newly uploaded to the document library


    • Type: Bug
    • Status: Verified
    • Resolution: Unresolved
    • Affects Version/s: DXP SP1
    • Fix Version/s: None
    • Component/s: Documents & Media
    • Labels:
    • Fix Priority:


      Problem Background

      Liferay Forms provides the ability for a custom DDMStorageAdapter.save(DDMStorageAdapterSaveRequest) method to save submitted form data, which overrides the default behavior which is to save the data to the Liferay database. The problem is that the url contained within the DDMFormFieldValue JSON text is not populated in JSON when a document is selected after being newly uploaded to the document library.

      Steps to Reproduce

      1. Create a new module with a CustomStorageAdapter that looks like this and deploy the module to $LIFERAY_HOME/osgi/modules:

      package com.mycompany;
      	immediate = true, property = {"ddm.storage.adapter.type=Custom"},
      	service = DDMStorageAdapter.class
      public class CustomStorageAdapter implements DDMStorageAdapter {
      	public DDMStorageAdapterSaveResponse save(
      		DDMStorageAdapterSaveRequest ddmStorageAdapterSaveRequest)
      		throws StorageException {
      		DMFormValues ddmFormValues =
      		Map<String, List<DDMFormFieldValue>> ddmFormFieldValuesMap =
      		List<DDMFormFieldValue> attachmentFormFieldValues =
      		for (DDMFormFieldValue attachmentFormFieldValue :
      			attachmentFormFieldValues) {
      			Value value = attachmentFormFieldValue.getValue();
      			JSONObject jsonObject = null;
      			try {
      				jsonObject = JSONFactoryUtil.createJSONObject(
      				long fileEntryId = jsonObject.getLong("fileEntryId");
      				String title = jsonObject.getString("title");
      				String url = jsonObject.getString("url");
      				System.out.println("fileEntryId=" + fileEntryId +
      					" title=" + title + " url=" + url);
      			catch (JSONException jsone) {
      				_log.error(jsone.getMessage(), jsone);
      		return null;
      	public DDMStorageAdapterDeleteResponse delete(
      		DDMStorageAdapterDeleteRequest ddmStorageAdapterDeleteRequest)
      		throws StorageException {
      		return null;
      	public DDMStorageAdapterGetResponse get(
      		DDMStorageAdapterGetRequest ddmStorageAdapterGetRequest)
      		throws StorageException {
      		return null;

      2. Click on "Content & Data -> Forms" in the Control Panel and create a form with a file upload field. Name the field "attachment".

      3. Before hitting the Save button, click the "..." button at the top of the page and then click on "Settings".

      4. Select "Custom" from the dropdown list for the custom storage option.

      5. Disable the autosave.

      6. Set the name of the form to be "MyForm"

      7. Save the form.

      8. Publish the form.

      9. Add the Forms portlet to a portal page and select "MyForm" to be displayed.

      10. Select a file with the file upload control

      11. Upload a new PDF file to the document library

      12. Select the file from the document library

      13. Click on Save in order to submit the form

      Expected Results

      The console output from System.out.println contains a non-null/non-empty relative URL of the submitted file. This is the URL that makes it possible to download the file.

      Actual Results

      The console output from System.out.println contain a null/empty URL for the submitted file.

      Note that when selecting an existing (previously uploaded) file with the document library file selection, the URL field will indeed be populated with a non-null/non-empty value.




            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created:
                Days since last comment:
                12 weeks, 2 days ago


                Version Package