Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Change path in JSON call

Avatar

Level 2

Hi,

I have created the component called "componentbox" and placed it in home page. when I try to edit the component the data are displaying fine in Edit mode,
because *.inifinity.json is there and retrieving the data properly.

Then I have created the sub-page under home page and the componentbox is displaying fine but when I try to edit it, it's not populating the exact data in Edit mode, its populating the default data, because for sub-page there is no *.infinity.json.
So want to point out to home page *.infinity.json.


Home page Json path -> en/home/jcr:content/componentBox
Subpage Json path -> en/home/subpage/jcr:content/componentBox instead of this URL want to point to Homepage Json path.

Kindly help me for this.

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi Srinivasan,

In general, the iParsys is going to be a better solution for what you are describing. Editing a component on Page A when it is stored on Page B can create authoring configuration as they are not necessarily aware that such a thing is going on.

That said, if you must do this, then the way to handle it is using a listener on the beforeloadcontent event on each widget to load its data from a different path.

Regards,

Justin

View solution in original post

9 Replies

Avatar

Correct answer by
Employee

Hi Srinivasan,

In general, the iParsys is going to be a better solution for what you are describing. Editing a component on Page A when it is stored on Page B can create authoring configuration as they are not necessarily aware that such a thing is going on.

That said, if you must do this, then the way to handle it is using a listener on the beforeloadcontent event on each widget to load its data from a different path.

Regards,

Justin

Avatar

Level 2

Hi Justin,

Below is the dialog.xml file, can you give example how to specify the path for each widget?  I am in learning stage of this JSON call in CQ5.

<items jcr:primaryType="cq:WidgetCollection">

        <tab1 title="Component Box" jcr:primaryType="cq:Widget" xtype="panel">

            <items jcr:primaryType="cq:WidgetCollection">

                <title name="./title" fieldLabel="Title" defaultValue="Component Title"
                    fieldDescription="Title to use for the Component box." width="200"
                    xtype="textfield" jcr:primaryType="cq:Widget" />
                <text name="./text" fieldLabel="Text" fieldDescription="Text to display."
                    width="200" xtype="textarea" jcr:primaryType="cq:Widget" />
                <phoneNumber name="./phoneNumber" fieldLabel="Phone Number"
                    fieldDescription="Phone number to display in the Component box."
                    width="200" xtype="textfield" jcr:primaryType="cq:Widget" />

Thanks,

C.Srinivasan.

Avatar

Employee

Srinivasan Chandrasekaran wrote...

Below is the dialog.xml file, can you give example how to specify the path for each widget?  I am in learning stage of this JSON call in CQ5.

In this case, I would strongly recommend that you use the iparsys.

Avatar

Level 2

Hi Justin,

You mean something similar like this:

<cq:include path="title" resourceType="foundation/components/iparsys" />

Thanks,

Srinivasan.

Avatar

Level 10

When you say that you created a component named "componentbox" -- are you following a developer article or blog somewhere?

I am trying to get a better idea of what you are trying to perform. 

Avatar

Level 2

Hi,

It's a existing component and in each page need to drag and drop from side-kick and to update the same content in each page.

Instead of that if content get modify in any pages then it should point to home page infinity.json, so that it will get update or modify in one place.

Home page Json path -> en/home/jcr:content/componentBox
Subpage Json path -> en/home/subpage/jcr:content/componentBox instead of this URL want to point to Homepage Json path.

if I see page view source for Home page and Sub page, it shows the path like this:

Home Page Json path - CQ.WCM.edit({"path":"/content/myapp/en/home/jcr:content/componentBox"
Sub page Json path - CQ.WCM.edit({"path":"/content/myapp/en/home/subpage/jcr:content/componentBox" - here want to change to home page path to - "/content/myapp/en/home/jcr:content/componentBox".

In all pages the component box values are displaying fine, handled in java class, If I click Edit button in "ComponentBox" then values are displaying the default value.

Kindly help me for this.

Avatar

Level 10

Have you tried modifying this path (which is only a node property) with the JCR API? 

Avatar

Level 2

Hi Smacdonald,

Tried to modify the node property path, but I couldn't able to find the path in JSON, can you help me on this?

Home Page Json path - CQ.WCM.edit({"path":"/content/myapp/en/home/jcr:content/componentBox"

Sub page Json path - CQ.WCM.edit({"path":"/content/myapp/en/home/subpage/jcr:content/componentBox" - here want to change to home page path to - "/content/myapp/en/home/jcr:content/componentBox".

How to find the path in JSON?

Avatar

Level 10

WHen you say find the path in JSON call - you are referring to using the Query Builder Restful API correct?

For example -- find all pages and order them by last modified

http://localhost:4502/bin/querybuilder.json?type=cq:Page&orderby=@jcr:content/cq:lastModified&orderby.index=true

Have you tried using the QueryBuilder API to locate your content? There are different ways you can use to search for your path.  

http://dev.day.com/docs/en/cq/current/dam/customizing_and_extendingcq5dam/query_builder.html