Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Refresh Granite Data Source when another Granite Field Changes Value

Avatar

Avatar
Validate 1
Level 1
jeremy_trpka-pe
Level 1

Like

1 like

Total Posts

10 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
jeremy_trpka-pe
Level 1

Like

1 like

Total Posts

10 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
jeremy_trpka-pe
Level 1

03-08-2020

Hello,

I am trying to figure out how to refresh a granite data source for a select field from a pathfield that I will like to also pass into the data source.

 

Basically:

  1. Set a path (pathToOptions) that will look at a content fragment model

  2. Datasource is called, each time the path value has changed in the dialog, to Sling Servlet to retrieve all fields of content fragment

  3. Author dialog generates options, for granite select drop down (cfOptions), with the fields from the data source.

 <pathToOptions jcr:primaryType="nt:unstructured"
     sling:resourceType="granite/ui/components/coral/foundation/form/pathfield"
     fieldLabel="CF Path"
     rootPath="/content"
     name="./pathToOptions"/>
 <cfOptions jcr:primaryType="nt:unstructured"
     sling:resourceType="granite/ui/components/coral/foundation/form/select"
     fieldLabel="CF Options"
     name="./cfOptions">
     <datasource jcr:primaryType="nt:unstructured"
         sling:resourceType="/bin/path/to/servlet"/>
 </resProperties>

(Variable names and paths are just generic)

 

Without so much knowledge of AEM Granite data sources and Apache Sling API; is there a viable method with the data source?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,429 likes

Total Posts

3,300 posts

Correct Reply

937 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,429 likes

Total Posts

3,300 posts

Correct Reply

937 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

04-08-2020

Hi,

This is not possible without javascript.

You need to write javascript to update dropdown on value change and dialog load.

 

In the below example I am choosing articles from pathbrowser field and updating dropdown with child pages.

 

example - https://github.com/arunpatidar02/aem63app-repo/blob/master/js/dynamic-dropdown.js

 

Answers (0)