update rootpath of pathfield based on the dropdown value | Community
Skip to main content
aem_dev1
Level 3
March 16, 2016
Solved

update rootpath of pathfield based on the dropdown value

  • March 16, 2016
  • 9 replies
  • 6536 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by aem_dev1

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

9 replies

smacdonald2008
Level 10
March 16, 2016

Are you working in Touch UI or Classic

aem_dev1
aem_dev1Author
Level 3
March 16, 2016

working on AEM 6.0 classic UI.

Please share the links for both classic & touch UI.

smacdonald2008
Level 10
March 16, 2016

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: {

aem_dev1
aem_dev1Author
Level 3
March 16, 2016

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.

Level 4
March 16, 2016

"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. 

Level 4
March 16, 2016

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. 

aem_dev1
aem_dev1AuthorAccepted solution
Level 3
March 21, 2016

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

ashisht85509954
Level 2
April 18, 2018

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

Level 2
July 3, 2018

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

Regards,

Bhavya S