Hi, I have a custom component. I have a path field inside it's dialog. If I enter the path of content fragment I want to have a drop down that populates all its variations. Could you tell me how I do this?
Solved! Go to Solution.
This can be achieved via calling the servlet if the CF will be having different variations or by using the datasource for the fixed set of the variations.
Approach I:
You can create datasource node structure with sling:resourceType of datasource as sling:resourceType (String) = /bin/dropdownList ( i.e. Path of the servlet implementing the data source for dynamic value). It will give the desire result of a dynamic dropdown as you can see below the screenshot.
For DataSource Servlet (/bin/dropdownList) Implementation you can refer to below articles:
https://redquark.org/aem/day-17-granite-datasources/
http://www.sgaemsolutions.com/2019/01/dynamically-populate-drop-down-values.html
Approach II:
You can create a listener for the adding the variation in a fixed list maintained at a fixed path e.g. /etc/variationList or /var/variationList. The dataSource will read the node and display the list.
I have not tried but thinking you can fix the CF folder parent path, if there are little variation of the variation List based on the folder path of the CFs. And this property can be fetched from one of the node property and this way it will be more dynamic as well.
Hope this helps
Thanks
Hi @sakethchandra02,
I think you can use dam/cfm/components/cfpicker which is dedicated widget for content fragment in combination with granite/ui/components/coral/foundation/form/select.
You can find working example of above in Content Fragment from Core components:
You should be able to adapt above solution in your custom component.
@sakethchandra02 I haven't tried this but you can try out the following approach.
https://jimfrenette.com/aem/components/dialog-coral-ui-select-cascade/
This is a very old article but you will get an idea about to fetch variation in the custom dialog
https://aemlab.blogspot.com/2018/09/aem-content-fragment-with-component.html
This can be achieved via calling the servlet if the CF will be having different variations or by using the datasource for the fixed set of the variations.
Approach I:
You can create datasource node structure with sling:resourceType of datasource as sling:resourceType (String) = /bin/dropdownList ( i.e. Path of the servlet implementing the data source for dynamic value). It will give the desire result of a dynamic dropdown as you can see below the screenshot.
For DataSource Servlet (/bin/dropdownList) Implementation you can refer to below articles:
https://redquark.org/aem/day-17-granite-datasources/
http://www.sgaemsolutions.com/2019/01/dynamically-populate-drop-down-values.html
Approach II:
You can create a listener for the adding the variation in a fixed list maintained at a fixed path e.g. /etc/variationList or /var/variationList. The dataSource will read the node and display the list.
I have not tried but thinking you can fix the CF folder parent path, if there are little variation of the variation List based on the folder path of the CFs. And this property can be fetched from one of the node property and this way it will be more dynamic as well.
Hope this helps
Thanks
Views
Likes
Replies
Views
Likes
Replies