Get parameter values from component | Community
Skip to main content
Level 2
Feb 20, 2023 12:35 PM UTC
Solved

Get parameter values from component

Hi @1905403 i had created an component with drop down the data source i get from servelet like :

<datasource 

jcr: primaryType:"nt: unstructured"

Sling: resourceType="/myservlet/path" />

It's possible to get parameter value from this datasource to my java model?

And what i am trying to do is dynamically populate value based on first drop down bring out the values on second dropdown like in first drop down choosing India the states of India bring out in second one?  What are ways to make it as possible please 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
arunpatidar
arunpatidarAccepted solution
New Participant
Feb 20, 2023 6:10 PM UTC

7 replies

arunpatidar
arunpatidarAccepted solution
New Participant
Feb 20, 2023 6:10 PM UTC
Level 2
Feb 22, 2023 3:47 AM UTC

Thanks @arunpatidar bro and all others to. Without using js it's possible bro ? 

Translate
arunpatidar
New Participant
Feb 22, 2023 5:41 AM UTC

Hi,

The datasource loads the dropdown at page/dailog load. If you want to change the values in the second dropdown list, you have to do it on the change event. This can only be done using Javascript.

Translate
Arun Patidar
Shiv_Prakash_Patel
New Participant
Feb 20, 2023 3:44 PM UTC

Hi @dilli_babu_22 , Your question is a little confusing, but as far as I understand, below are the solutions.

If your data source structure is as below and you want to get the value of the tag path in the servlet class, then you can get it with the help of a resource.

<!-- # cq:dialog xml -->
<items jcr:primaryType="nt:unstructured">
<colorTags
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/select"
fieldDescription="Select the color tags"
fieldLabel="Color Tags"
multiple="{Boolean}true"
name="./colorTags">
<datasource
jcr:primaryType="nt:unstructured"
sling:resourceType="/bin/colorTagLists"
tagsPath="/content/cq:tags/learning/color"/>
</colorTags>
</items>
<!-- # cq:dialog xml -->

Getting tagsPath in servlet class :

resourceResolver = request.getResourceResolver();
pathResource = request.getResource();
resourceList = new ArrayList<>();

/* Getting AEM Tags Path given on datasource Node */
String tagsPath = Objects.requireNonNull(pathResource.getChild("datasource")).getValueMap().get("tagsPath", String.class);
assert tagsPath != null;

Please refer to this article for full details - https://unlocklearning.in/dynamic-dropdown-in-aem/ 

I hope this could help you!!!

Regards

Shiv

 

 

Translate
Shiv Prakash
krishna_sai
New Participant
Feb 20, 2023 1:48 PM UTC

Hi @dilli_babu_22 , not sure what the ask is here but if you want some additional data to your java servlet, you can add properties to the node and read them in your servlet by getting resource valuemap.

Hope this helps,

Thanks,

Krishna

Translate
Shashi_Mulugu
New Participant
Feb 20, 2023 1:31 PM UTC

@dilli_babu_22 What parameter value you want to pass? how would you fetch the value from?

Translate