I have a use case in which AEM dialog multifield producing authoring data to be needed in a servlet for making dynamic dropdown options. Some other component which is having dropdown widget which calls the servlet using data source for dynamic dropdown. I have achieved all the requirement except one how does servlet get to know the dynamic path of multifield component are being used on the page. I also archived this one using servlet OSGI configuration but some business reason OSGI configuration cannot be used.
Requirement is such as.
1. multifield component responsible for storing key value pair data for dynamic dropdown.
2. Proposal is servlet needs to retrieve the multifield authoring data and it need to expose as data source for another component.
3. Another component calls the servlet through data source.
Restriction: ACS-Commons and OSGI Config cannot be used,
Please give you valuable thought on this.
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @sparwaiz
This is how I understood your problem.
1. You have a component with a multifield in its dialog where you author key value pairs.
2. Another component will need to fetch those values via servlet via datasource node into a dropdown of its dialog.
Hi,
Have a page in your structure which won't be accessible to outside world (end user), you may block on dispatcher.
This page will have a component(may be named config component) with multifield which will accept key and value .
Key can be constant predefined in code and mentioned in authoring guide, same key(constant ) will be used by author as key in multifield & the path will be value of dynamic path of multifield component.
Now this special page path either you can hard code and will be same on all instance or atleast this special page path can be taken as osgi config.
Note:-On this page we can have other author-able key value constant similar to osgi config which are not that rigid to be part of osgi config but dynamic and authorable
You can pass data from your datasource by setting property on your datasource Node, For e.g
<datasource
jcr:primaryType="nt:unstructured"
sling:resourceType="servlet_resourceType"
multifieldPath="multifield_path"/>
Then you can retrieve this in your servlet and process it
request.getResource().getChild("datasource").getValueMap().get("multifieldPath",
"default_multifield_path");
Hope this helps.
hi @sparwaiz ,
Hope you have already found the answer. If not please check below
If the ask is to look for how the multifield component authored on a page in your servlet, you can get that using the "sling:resourceType" of that component from the page path.
Sample code to fetch dynamic component from a page assuming thats your question
ResourceResolver resourceResolver = request.getResourceResolver();
PageManager pageManager = resourceResolver.adaptTo(PageManager.class);
Page multiFieldComponentPage = pageManager.getPage("multifieldPagePath");
if (null != multiFieldComponentPage) {
Resource responsiveGridResource = resourceResolver.getResource(multifieldPagePath+
"/" + JcrConstants.JCR_CONTENT+"/root/responsivegrid");
if (null != responsiveGridResource) {
if(responsiveGridResource.getResourceType().equalsIgnoreCase("componentResourceType"))
{
return responsiveGridResource.getPath();
}
}
}
Hi @sparwaiz
This is how I understood your problem.
1. You have a component with a multifield in its dialog where you author key value pairs.
2. Another component will need to fetch those values via servlet via datasource node into a dropdown of its dialog.
Hi @sparwaiz
Please check https://aemlab.blogspot.com/2022/01/aemaacs-touch-ui-dialog-dynamic-dropdown.html