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

Reference new properties in HTML file

odabio
Level 2
Level 2

Hello

 

I’m struggling to display the new properties that I added in form options..

Just to give a little bit of context, I’m want to extend the form option component  and add some new option (Title, URL and Image), I’ve successfully added those option as we can see in the image below

odabio_0-1634986510733.png

 

My issue is that I cannot reference the newly added option in my html (imageview.html) here’s my here’s the content of the file:

odabio_1-1634986510740.png

 

 

CRXDE.png

 

 

 

 

 

 

 

 

 

Gist link to some files:

_cq_dialog/.content.xml: https://gist.github.com/odaBio/e8ebb790d0541b6cb295d2b72dbb6246

Imageview.html: https://gist.github.com/odaBio/e9d97c25539f949e108487e1f301ddaf

ImageView.javahttps://gist.github.com/odaBio/bb977ff6296d9fbdecee481b8c18540c

ImageViewImpl.javahttps://gist.github.com/odaBio/3cad00f7b5014b69abbe0b5aa1501053

OptionItem.javahttps://gist.github.com/odaBio/4f52045f8b124e6dcd2a3fa7b858c2de

OptionItemImpl.javahttps://gist.github.com/odaBio/5087321aec7016564383b0c44ee8ab1e

 

Is there any way that I can reference the Title, url and image in my HTML ?

Thanks in advance.

1 Accepted Solution
MohitKumarK
Correct answer by
Level 4
Level 4

Hi @odabio ,

I can see you have created a new sling model for ImageView, but in the HTL you are using "com.adobe.cq.wcm.core.components.models.form.Options" which may not have your new members. What you can do is extend Options model with your sling model and then add you new members and then you can refer sling model which you have created.

 

Refer this article https://github.com/adobe/aem-core-wcm-components/wiki/Delegation-Pattern-for-Sling-Models on extending a core component.

 

Thanks!

View solution in original post

7 Replies
Asutosh_Jena_
Community Advisor
Community Advisor

HI @odabio 

 

Have you included these additional properties in the sling model class where you are trying to refer the object in HTL?

 

If these additional fields are not included, you will not be able to use the fields in HTL and it will always return null.

 

Thanks!

bangar50
Level 7
Level 7

Hi @odabio ,

      Did you inject the above 3 field in the options sling model.

Regards,

Sanjay

MohitKumarK
Correct answer by
Level 4
Level 4

Hi @odabio ,

I can see you have created a new sling model for ImageView, but in the HTL you are using "com.adobe.cq.wcm.core.components.models.form.Options" which may not have your new members. What you can do is extend Options model with your sling model and then add you new members and then you can refer sling model which you have created.

 

Refer this article https://github.com/adobe/aem-core-wcm-components/wiki/Delegation-Pattern-for-Sling-Models on extending a core component.

 

Thanks!

View solution in original post