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

[AEM Gems Webinar] Accelerating Experience Manager as a Cloud Service development with Rapid Development Environments
SOLVED

check box type

Avatar

Level 2

Hi,

I have a checkbox on dialog, with 

Xtype=selection

type=checkbox

name=./facebook.

 

so when i check the checkbox, i want the facebook icon to be displayed, and not display when unchecked.

this is my code

 <div class="mbr-contacts__column col-sm-4" data-form-type="formoid">

 

                <span>

               

                    <a href="https://www.facebook.com"><img src="/content/dam/demo/images/facebook_alt.png" alt="facebookapp"></a>


                </span>          

 


            </div>
 

when i went through, i found that we need to add this additional scriplet: <%=properties.get("facebook",String[].class)%> , if it is true, where shoulf i add.

1 Accepted Solution

Avatar

Correct answer by
Level 2

Hi Shreyas

    Could you please elaborate on your question?

If my understanding is correct you are trying to add a facebook icon in your presentation HTML, when the user checks the checkbox in the dialog ?

If so, you can if properties.get("facebook") is returning the expected value and according to the result you can write an if condition to hide or show your

<a href="https://www.facebook.com"><img src="/content/dam/demo/images/facebook_alt.png" alt="facebookapp"></a>

 

Please confirm if you are writing the code in scriptlet/ JSTL/Sightly???

 

Thanks

Veena

View solution in original post

0 Replies

Avatar

Correct answer by
Level 2

Hi Shreyas

    Could you please elaborate on your question?

If my understanding is correct you are trying to add a facebook icon in your presentation HTML, when the user checks the checkbox in the dialog ?

If so, you can if properties.get("facebook") is returning the expected value and according to the result you can write an if condition to hide or show your

<a href="https://www.facebook.com"><img src="/content/dam/demo/images/facebook_alt.png" alt="facebookapp"></a>

 

Please confirm if you are writing the code in scriptlet/ JSTL/Sightly???

 

Thanks

Veena

Avatar

Level 10

You need to write code in the component and read whether the field was clicked using 

<%=properties.get("facebook",String[].class)%> 

in the component's JSP or HTL. Then you can use code in the component to display the Facebook icon in the component. 

Avatar

Level 4

Hi Shreyas L,

It is just if condition

If you are using sightly/AEM6 simply write

<sly data-sly-test="${properties.facebook}"> <a href="https://www.facebook.com"><img src="/content/dam/demo/images/facebook_alt.png" alt="facebookapp"></a> </sly>

Avatar

Administrator

Agreeing with both of the approaches.

1. By Veena :-

Get the value of check box by "properties.get("facebook")" and using condition you can add the image.

Otherwise you can also change CSS to hide by "visibility: hidden".

2. If it is HTL (formerly knows as Sightly),

    <sly data-sly-test="${properties.facebook}">
    <a href="https://www.facebook.com"><img src="/content/dam/demo/images/facebook_alt.png" alt="facebookapp"></a>
    </sly>

I hope this would help you.

Thanks and Regards

Kautuk Sahni

Avatar

Level 2

hi veena,

you are right i am trying to display facebook icon using the check box, it shouldnt display if un-checked.

I am writing my code in jsp.

so <data-sly-test> wouldnt work right?

Avatar

Level 2

Hi Shreyas

    Sorry for the late response. So it should be simple as explained by me, scott and kautuk. Hope you know how to handle if else condition in JSP.

     And I would suggest you to move to JSTL or if using AEM 6+ , use sightly. Writing in scriplets anymore doesn't seem to be a good quality coding . Just a thought 🙂 

 

Thanks

Veena

Avatar

Level 1

Hi Veena,

I created one checkbox as below in my dialog under the component.

text: Mrp

value: true

uncheckvalue: false

resourcetype: checkbox out of box comp

i made it to returning the values in content folder- jcr root  as true and false,  when tick and untick the checkbox.

Now i want the below solution,

Condition: I want to show/hide some content( for eg: mrp-rate) on the page,  If i tick/untick my checkbox.

I need to add if condition using sightly. How to achieve this