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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

update rootpath of pathfield based on the dropdown value

Avatar

Level 3

Hello,

I want to update the rootpath of pathfield in authoring dialog based on other filed value (dropdown selection). Appreciated for quick pointers on this.

Thanks.

1 Accepted Solution

Avatar

Correct answer by
Level 3

I did not find solution at https://helpx.adobe.com/experience-manager/using/jstl.html.

But i have fixed the problem as below. When user click on path field it will open a browse dialog (At back-end, in pathfield.js it will invoke a "onTriggerClick" function. In that function it will check if browseDialog object is null or not. If yes it will create new browseDialog (configs based on the rootPath property configured in dialog.xml, if nothing set, by default takes /content) and shown to user.

As per my requirement, when i change the dropdown value in authoring dialog, path field rootpath should be changed. After i changed the dropdown value, click on  path field will again trigger "onTriggerCallFunction function"  . As per below code  it should change the rootPath. But it will not change the rootpath and show the previous value. Because "onTriggerCallFunction" will not create new browsedialog, it will show the same browsedialog crated with previous value. One way to fix this add "parhfiledObj.browseDialog=null" after setting the treeRoot in if statement

var selectValue  = pane.find(...);

var pathfiledObj = panel.find(....)

if (selectValue == "c1"){pathfiledObj.treeRoot.name="/content....")}

Fix: pathfiledObj.browseDialog=null

if (selectValue == "c1"){pathfiledObj.treeRoot.name="/content....");pathfiledObj.browseDialog=null;}

Let me know for more details

View solution in original post

9 Replies

Avatar

Level 3

working on AEM 6.0 classic UI.

Please share the links for both classic & touch UI.

Avatar

Level 10

See this AEM article - it covers this as part of building a component that uses a Pathfield in a Multifield: 

https://helpx.adobe.com/experience-manager/using/jstl.html

 this.devImage = new CQ.form.PathField ({
                fieldLabel: "Image",
                rootPath:"/content/dam",
                regex :/\.(png|jpg|jpeg|gif|tiff|bmp|pnm|pgm|pbm|ppm|psd|eps|dng)$/,
                regexText : "Please choose an image file",
                editable : false,
                allowBlank: false,
                width: 225,
                listeners: {

Avatar

Level 3

i am able to set Rootpath. 

In my case authoring dialog has two fields. Type(dropdown) & target (path field). Based on the selection in type droodown i want to set the rootpath dynamically. i tried setting dailog...getField().treeRoot.name to required path but it didnt work.

Avatar

Level 4

"i want to set the rootpath dynamically"

Here is the reference for this data type: 

https://docs.adobe.com/docs/en/cq/5-3/widgets-api/index.html?class=CQ.form.PathField

Set rootPath using code. 

Avatar

Level 4

In this example - there is a package. 

https://helpx.adobe.com/experience-manager/using/jstl.html

I am going to try and set rootPath of a Pathfield in an event handler (in the JS file) and report back. It should display the value that is set. 

Avatar

Correct answer by
Level 3

I did not find solution at https://helpx.adobe.com/experience-manager/using/jstl.html.

But i have fixed the problem as below. When user click on path field it will open a browse dialog (At back-end, in pathfield.js it will invoke a "onTriggerClick" function. In that function it will check if browseDialog object is null or not. If yes it will create new browseDialog (configs based on the rootPath property configured in dialog.xml, if nothing set, by default takes /content) and shown to user.

As per my requirement, when i change the dropdown value in authoring dialog, path field rootpath should be changed. After i changed the dropdown value, click on  path field will again trigger "onTriggerCallFunction function"  . As per below code  it should change the rootPath. But it will not change the rootpath and show the previous value. Because "onTriggerCallFunction" will not create new browsedialog, it will show the same browsedialog crated with previous value. One way to fix this add "parhfiledObj.browseDialog=null" after setting the treeRoot in if statement

var selectValue  = pane.find(...);

var pathfiledObj = panel.find(....)

if (selectValue == "c1"){pathfiledObj.treeRoot.name="/content....")}

Fix: pathfiledObj.browseDialog=null

if (selectValue == "c1"){pathfiledObj.treeRoot.name="/content....");pathfiledObj.browseDialog=null;}

Let me know for more details

Avatar

Level 2

I have same requirement for tagpicker, can you please share the code snippet that you used for this.

Avatar

Level 2

Could you please share the code snippet a little more elaborately, it would be really helpful. I have the same requirement.

Regards,

Bhavya S