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

Replies

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

31-05-2018

Are you trying to populate values that are displayed in a HTL front end component? 

Avatar

Avatar
Level 1
huvu
Level 1

Likes

0 likes

Total Posts

10 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
huvu
Level 1

Likes

0 likes

Total Posts

10 posts

Correct Reply

0 solutions
View profile
huvu
Level 1

31-05-2018

Are you trying to populate values that are displayed in a HTL front end component? -> Nope

I want populate content for dialog component which base on node name and resourType.

----------------------

Thanks for your quick reply. Let me rephrase it there.

I have a page template which is using HTL. The page components will be rendered via code bellow code.

<div data-sly-resource="${ field.variable @ resourceType=field.fieldType,description=field.description, variable=field.variable,decorationTagName='div'}"></div>

It will render a list of component there. In the list of component I have a special component which is call Dropdown field.

It has dialog config look like

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
   jcr:primaryType="cq:Dialog"
   title="Dropdown field"
   xtype="panel">

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

   <content
   jcr:primaryType="cq:Widget"
   fieldLabel="Content Data"
   fieldDescription="Output JSON data"
   name="./content"
   options="$PATH.option.json"
   type="select"
   xtype="selection"/>

   </items>

</jcr:root>

My issue that is populate content data for this selection/dropdown in the component dialog. My servlet rely on node name and resourceType of this component to populate/resolve content data for the selection/dropdown in the dialog.

I had googled with these key words bellow but not help much.

"aem resourceType force create node"

"how to pass value to AEM widget dialog"

P/S:

Full rendering page HTL code

<div data-sly-list.field="${model.listContentField}">

   <div data-sly-test.hasData="${field}" style="margin-top: 25px">

   <fieldset>

   <legend data-sly-test="${field.required}" style="color: chocolate" data-sly-text="${field.description} || Required field"></legend>

   <legend data-sly-test="${!field.required}" data-sly-text="${field.description}"></legend>

   <div data-sly-resource="${ field.variable @ resourceType=field.fieldType,description=field.description, variable=field.variable,decorationTagName='div'}"></div>

   </fieldset>

   </div>

</div>

Regards & Thanks,

Hung Vu

Avatar

Avatar
Validate 1
Level 1
rigor
Level 1

Like

1 like

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
rigor
Level 1

Like

1 like

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
rigor
Level 1

01-06-2018

If you want your component to have some nodes created automatically you have to make use of cq:template. You create it beside cq:dialog. If you want to have node called image_node created automatically, your cq:template would look something like this:

<jcr:root jcr:primaryType="nt:unstructured" ...>

    <image_node jcr:primaryType="nt:unstructured" sling:resourceType="path/to/component/definition"/>

</jcr:root>

Avatar

Avatar
Level 1
huvu
Level 1

Likes

0 likes

Total Posts

10 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
huvu
Level 1

Likes

0 likes

Total Posts

10 posts

Correct Reply

0 solutions
View profile
huvu
Level 1

03-06-2018

Thanks @igorr76272295

For my case. It won't work as expected with data-sly-resource.

Note that there are we have two use case using of a component.

#1: We use sly API to give a component (this is my case)

<div data-sly-resource="${ childField.path @ resourceType=childField.fieldType, description=childField.description, variable=childField.variable, decorationTagName='div'}"></div

>

#2: Content author will drag & drop component from sidekick into the existing pars in a page.

P/S: It works in case we drag & drop component into the parsys.

Regards & Thanks,

Hung Vu

Avatar

Avatar
Validate 1
Level 1
rigor
Level 1

Like

1 like

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
rigor
Level 1

Like

1 like

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
rigor
Level 1

03-06-2018

As you said, cq:template node of the component has the desired effect only in case author adds the component to page - true. For the first use case, however, you have to include the respective nodes in the template of your page, e.g.,:

<jcr:root jcr:primarytype="cq:Template" ...>

     <jcr:content jcr:primaryType="cq:PageContent" ...>

          <your_component sling:resourceType="path/to/your/component">

               <image_node jcr:primaryType="nt:unstructured" sling:resourceType="path/to/component/definition"/>

          </your_component>

     </jcr:content>

</jcr:root>

Avatar

Avatar
Level 1
huvu
Level 1

Likes

0 likes

Total Posts

10 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
huvu
Level 1

Likes

0 likes

Total Posts

10 posts

Correct Reply

0 solutions
View profile
huvu
Level 1

03-06-2018

Hi @igorr76272295,

I got what you mean. Your case is populating component as static via template configuration with pre-define node name and resourceType for that node.

It's not my case. My components are generated dynamically.

My real use case:

- I have a page configuration which config node name and resourceType for a component to be render in other page

- I have another page which use sly to render the configuration components which are configured above. That is reason you saw my sample code which has a Model to get list components which are configured from other page.

Thank you!,

Regards,

Hung Vu

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,089 likes

Total Posts

3,123 posts

Correct Reply

1,063 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,089 likes

Total Posts

3,123 posts

Correct Reply

1,063 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

04-06-2018

That means that your constraints do not allow you to create a template with the proper components already contained, but you rather need to determine the name and resource type when that page is being created (based on some data stored somewhere in the JCR)?

TBH that's a rather unusal requirement. The problem is that at the the moment you create the page this data influences the name and (more important) the resourcetype of that component; but I don't see any way to change it afterwards; and at some point you will have the requirement to do that. Also you need to customize a lot of make this really happen (and creating the nodes on first rendering should never be an option ...).

If you cannot determine the exact type of component during creation time I would rather create a proxy component, which can be configured by JCR properties; and then based on the configuration it behaves like the components you want it to be (either by implementing a huge switch statement or by rather doing a sling:include with the proper resourcetype set).

Jörg

Avatar

Avatar
Validate 1
Level 1
rigor
Level 1

Like

1 like

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
rigor
Level 1

Like

1 like

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
rigor
Level 1

04-06-2018

In that case you have to use Dynamic Templates that were introduced in AEM 6.2. Have a look here -> Creating Page Templates

Avatar

Avatar
Level 1
huvu
Level 1

Likes

0 likes

Total Posts

10 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
huvu
Level 1

Likes

0 likes

Total Posts

10 posts

Correct Reply

0 solutions
View profile
huvu
Level 1

03-09-2018

Thanks @igorr76272295Jörg Hoh

My business has the same idea which Creating Page Templates does, but it doesn't match 100% our use case. My business can map with Adobe Experience Manager Help | Using Content Fragments in AEM​.

My business reqquirement

#1: Create a template which can define list of field for a Form

#2: Create another template which its page content will point to page content which is created by template above (#1).

#3: We can authoring for page content which is created at (#2)

#4: We expose an API to export data as JSON

Fortunately, during debug I got node name of editing component which base on request path of component request (without node is created), so that i can solve my issue.