How to Dynamically Change Asset Browser Root Path Based on PathBrowser Selection in AEM Dialog?
Scenario
I have an AEM component dialog with two fields:
- PathBrowser field - selects content pages from /content/mysite/locale/news/
- Asset Browser field - browses images from /content/dam/mysite/
Requirement
When a user selects a specific post path in the PathBrowser, I need the Asset Browser's root path to dynamically change to match the corresponding DAM folder structure.
Example:
- PathBrowser selects: /content/mysite/en-US/news/article1
- Asset Browser root should automatically change to: /content/dam/mysite/en-US/news/article1
Current Dialog Structure
<!-- Post Path Selector --> <selectspecificpost jcr:primaryType="nt:unstructured" sling:resourceType="cq/gui/components/coral/common/form/pathfield" fieldLabel="Post Path" name="./selectSpecificPost" rootPath="/content/mysite/locale/news" required="{Boolean}true"/> <!-- Image Asset Browser --> <imagepath granite:class="assetbrowser" jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/textfield" fieldLabel="Image Path" name="./imagePath" required="{Boolean}true"> <granite:data jcr:primaryType="nt:unstructured" assettype="images" mimeType="image/*" mode="single" rootpath="/content/dam/mysite"/> </imagepath>
Question
What's the most efficient and reliable way to achieve this dynamic root path behavior in AEM 6.5.x Touch UI dialogs?
Should I be using:
- Client-side JavaScript with Granite UI APIs?
- Custom Sling Resource Types?
- Server-side approach with Sling Models?
- AJAX servlets for dynamic configuration?
Looking for best practices and performance considerations for Touch UI dialog field interactions.
Environment: AEM 6.5.x, Coral UI 3, Granite UI