cancel
Showing results for 
Search instead for 
Did you mean: 

SimplePicker widget is not rendering the Nested List of JSON array.

satheeshkumar
Champ in-the-making
Champ in-the-making
Hi All,

I have a SimplePicker widget, the sample code is shown below,


var imageLibraryPicker = {
   name : "alfresco/forms/controls/SimplePicker",
   config : {
      label : "Pick Image Libraries",
      description : "This is a simple picker publishes a request to get data to display",
      visibilityConfig : {
         initialValue : false,
         rules : [ {
            targetId : "SHOW_OTHER_FIELDS",
            is : [ true ]
         } ]
      },
      name : "imageLibraries",
      noItemsMessage: "No Libraries Available!",
      loadDataPublishTopic : "ALF_CRUD_GET_ALL",
      loadDataPublishPayload : {
         url : "retrieve-library-list?retrieve=Image%20Library"
      },
      itemsProperty : "imageLibrariesList.image",
      itemKey : "prop_cm_name",
      propertyToRender : "prop_cm_name",
      availableItemsLabel : "Available",
      pickedItemsLabel : "Currently Selected"
   }
};


My Sample JSON Nested Array response rendered by my webscript URL
http://localhost:8080/alfresco/service/retrieve-library-list?retrieve=Image%20Library
is,


{
  "imageLibrariesList": [
    {
      "image": [
        {
          "prop_cm_name": "Images1"
        },
        {
          "prop_cm_name": "Images2"
        }
      ]
    },
    {
      "background": [
        {
          "prop_cm_name": "Background2"
        },
        {
          "prop_cm_name": "Background1"
        }
      ]
    },
    {
      "stock": [
        {
          "prop_cm_name": "Stock1"
        },
        {
          "prop_cm_name": "Stock2"
        }
      ]
    },
    {
      "photo": [
        {
          "prop_cm_name": "Photo1"
        },
        {
          "prop_cm_name": "Photo2"
        }
      ]
    },
    {
      "graphics": []
    }
  ]
}


I was expecting
Images1
and
Images2
would be rendering as per the above configuration, but it is not rendering anything and showing
Could not load properties


Can someone let me know, is there anything wrong in my JSON response or the way I access
itemsProperty : "imageLibrariesList.image"
.

Thanks in Advance,
2 REPLIES 2

satheeshkumar
Champ in-the-making
Champ in-the-making
Here is the Simple JSON Array List(i.e Non Nested compared to my previous post),
{
  "stockImagesLibraryList": [
    {
      "prop_cm_name": "Stock2"
    },
    {
      "prop_cm_name": "Stock1"
    }
  ],
  "backgroundImagesLibraryList": [
    {
      "prop_cm_name": "Background2"
    },
    {
      "prop_cm_name": "Background1"
    }
  ],
  "photoImagesLibraryList": [
    {
      "prop_cm_name": "Photo1"
    },
    {
      "prop_cm_name": "Photo2"
    }
  ],
  "imagesLibraryList": [
    {
      "prop_cm_name": "Images2"
    },
    {
      "prop_cm_name": "Images1"
    }
  ],
  "graphicsImagesLibraryList": []
}


And I am able to access this properly with the below SimplePicker,
{
   name : "alfresco/forms/controls/SimplePicker",
   config : {
      label : "Pick Image Libraries",
      description : "This is a simple picker publishes a request to get data to display",
      visibilityConfig : {
         initialValue : false,
         rules : [ {
            targetId : "SHOW_OTHER_FIELDS",
            is : [ true ]
         } ]
      },
      name : "imageLibraries",
      noItemsMessage: "No Libraries Available!",
      loadDataPublishTopic : "ALF_CRUD_GET_ALL",
      loadDataPublishPayload : {
         url : "retrieve-library-list?retrieve=Image%20Library"
      },
      itemsProperty : "imagesLibraryList",
      itemKey : "prop_cm_name",
      propertyToRender : "prop_cm_name",
      availableItemsLabel : "Available",
      pickedItemsLabel : "Currently Selected"
   }
};


It looks like, I am not able to access the Nested JSON Array in Simple Picker,
Please guide me if I am wrong.

Thanks in Advance,

ddraper
World-Class Innovator
World-Class Innovator
It should still be possible to access an array element if you are 100% sure that the index will never change, e.g. you could set itemsProperty to be "imageLibrariesList.0.image" (this assumes that the "image" object will always be the first element in the "imageLibrariesList" array). However, a better solution would be to use a custom service (rather than the CrudService) so that you can "normalize" your data into whatever data structure you require.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.