Expand my Community achievements bar.

SOLVED

How to reference a static list for Form option component

Avatar

Level 3

Hello everyone

I’m trying to create a dropdown list were the list items is a list of countries (I have a list of countires in an XML and json format) and I want to load that static in /apps so I can reference it in form options (picture below)

formoption.png

 

My question is: Is there anyway that I can load my defined list ? or do I need to create each node for each country (picture below)?

onebmx.png

 

Thanks in advance.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

In this case you can use datasource and return list items, you can create datasourec from json as well

e.g. https://aemlab.blogspot.com/2019/07/aem-touch-ui-dropdown-from-json.html



Arun Patidar

View solution in original post

6 Replies

Avatar

Level 3

Hi @arunpatidar 

Thanks for your answer but there's no way that I can read I defined list ? 

My list have more than 150 values (countries) and i would take too much time to create a node for each option...

I would be easier if I could read my defined list, If any ideas about how i could read the list it'll be very helpfull.

 

Thanks

 

 

Avatar

Correct answer by
Community Advisor

Hi,

In this case you can use datasource and return list items, you can create datasourec from json as well

e.g. https://aemlab.blogspot.com/2019/07/aem-touch-ui-dropdown-from-json.html



Arun Patidar

Avatar

Level 3

Hi @arunpatidar 

Can i select an unstructured node with all the data? here my crx 

CRXDE.png

 in my IDE

 

onebmx_aem_countries_.content.png

I want something like this so i can just copy the countries from my XML..

Avatar

Community Advisor

Yes, you can do it via datasource, there you can parse or query this nodes and create dropdown using datasource.



Arun Patidar

Avatar

Community Advisor

Hi @odabio, I am not sure if this is one time action or you would like to maintain your list in the future, but you can consider below solutions that should allow you to automate list creation process.

  1. Data Importer functionality from ACS Commons - however it requires Excel file as an input - so you will need to transform your XML or JSON file into excel to use it.
    https://adobe-consulting-services.github.io/acs-aem-commons/features/mcp-tools/data-importer/index.h...
  2. You can create simple java class that will do the import job, here is a nice example of servlet that allows to import data in JSON format https://blogs.perficient.com/2021/08/16/loading-json-content-into-aem/
  3. If you are using Groovy console you can also create groovy script that will create the list from XML or JSON - this is quite similar approach to the one described in point 2.