Expand my Community achievements bar.

Get ready! An upgraded Experience League Community experience is coming in January.
SOLVED

checkout No default value

Avatar

Level 2

dialog  I add checkout  ,I expect to have initial values when the component is not edited

<boutiqueCheckout
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/checkbox"
uncheckedValue="true"
name="./boutiqueCheckout"
text="Open in new window"
value="{Boolean}false"/>

 

html 中我打印

<div>232323========${properties.boutiqueCheckout}</div>

 

Output results on the final page
<div>232323========</div>

 

 

How should I renovate it,

1 Accepted Solution

Avatar

Correct answer by
Level 3

There is a possible way to have default values for the component through template.
Go to the template in the initial content xml add the component's default value

<jcr:content>

<root>

<boutiqueCheckoutComponent
            jcr:primaryType="nt:unstructured"
            boutiqueCheckout="true"/>

</root>

</jcr:content>

 

View solution in original post

2 Replies

Avatar

Employee Advisor

Hello @guodongha ,

 

The checkbox value isn’t stored until the dialog is saved, so properties.boutiqueCheckout is null initially.

 

fix:
Use a default value in HTL to handle unedited components:

<div>232323========${properties.boutiqueCheckout @ context='boolean', default=false}</div>


-> This ensures it prints false by default (and true once the author checks it and saves).



Avatar

Correct answer by
Level 3

There is a possible way to have default values for the component through template.
Go to the template in the initial content xml add the component's default value

<jcr:content>

<root>

<boutiqueCheckoutComponent
            jcr:primaryType="nt:unstructured"
            boutiqueCheckout="true"/>

</root>

</jcr:content>