Hi Team,
Hope you all are doing good.
I need a help on one requirement.
We have one component and it's dialog contains two tabs, (tab1, tab2 respectively).
We are using this component on experience fragement to get headless cms.
With the current implementation, there is sling model exporter defined already for this component
json output is in below format,
"tab1":{
"id" :
}
"tab2":{
"firstname":
"lastname":
}
For achieving tab2 in above json format i have written another sling model and used it as @ChildResource in sling model exporter defined.
I tried both ways by using @default(values=" ") and also tried with value="" in content.xml of dialog.
Both options need to tick on the dialog then default data is visible in the json format.
Could you please give any idea/ solution to achieve the requuirement without touching the tick of the dialog.
Thanks in advance.
Regards,
Pavan
#HeadlessCMS, #Experiencefragment
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Please see if you can use cq:template to create a default node.
The ChildResource annotation is understanding that the resource does not exist. Hence, the Sling Model might also not be coming into action
http://www.sgaemsolutions.com/2018/02/cqtemplate-and-cqtemplatepath.html
Can you please elaborate "
Both options need to tick on the dialog then default data is visible in the json format. "
Hi @aanchal-sikka ,
Thanks for reply.
Let me elaborate more.
I tried below 2 options.
Option 1 : Using value=" " in content.xml of the dialog
Option 2 : Using @Default(values=" ") in the sling model created for getting tab2 values.
for both options, we need to tick (highlighted below) of the dialog, then default values appears in json format
Regards,
Pavan
Can you please check whats the difference in the state of the component before and after you save the Dialog? I mean difference in values of component properties when viewed via CRXDE
Hi @aanchal-sikka ,
for getting tab2 values as json format shared above.
I made sling model, used the same as @ChildResource in existing model exporter class.
Observation for state of component before saving is it just creating a tab1 node.
After saving the dialog, it will create tab2 node inside tab1 node and default values appear as a properties of tab2 node.
Regards,
Pavan
Please see if you can use cq:template to create a default node.
The ChildResource annotation is understanding that the resource does not exist. Hence, the Sling Model might also not be coming into action
http://www.sgaemsolutions.com/2018/02/cqtemplate-and-cqtemplatepath.html
Hi @phampi ,
If understood correctly you want to return exporter json default value even if component dialog is not authored(dialog not submitted).
just make sure you imported correctly and no typo in fields.
import org.apache.sling.models.annotations.Default;
@ValueMapValue
@Default(values = StringUtils.EMPTY)
private String heading;
Hi @phampi,
You can try the below ways:
Regards,
Ramkumar
@phampi Did you find the suggestion helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!
Views
Replies
Total Likes