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

How to set default value in a Touch UI select element?

Avatar

Level 2

How to set default value in a Touch UI select element in AEM 6.5

 

@arunpatidar  @DEBAL_DAS 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor
6 Replies

Avatar

Community Advisor

Hi @naruk89179065 ,

I believe you are using 

sling:ResourceType: granite/ui/components/foundation/form/select

In that case, you can use cq:template node to set initial default values for any kind of select datasource, textfield, radiogroup, checkbox etc. resource type.

Just add cq:template node inside AEM component.

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0"
    jcr:primaryType="nt:unstructured"
    <jcrPropertyName>="<default value here>"/>

Screen Shot 2022-06-09 at 1.49.40 PM.png

Hope that helps you!

Regards,

Santosh

 

Avatar

Community Advisor

@naruk89179065,

It really depends on which granite UI field are you targeting. Typically you will add an extra property to the XML configuration.


But here's a quick run down for which property sets a default value for which Granite UI fields that you are targeting:

  1. checkbox - value, link reference 
  2. textarea - value, link reference
  3. pathfield - cannot set default, link reference
  4. select - selected, link reference
  5. radiogroup - checked, link reference
  6. numberfield - value, link reference
  7. fileupload - cannot set default, link reference
  8. colorpicker - value, link reference

Checkout the full guide, cheat sheet reference guide which include code examples and pre-configured touch UI - https://sourcedcode.com/blog/aem/aem-granite-ui-1-0-form-components-xml-cheat-sheet-reference-guide

Avatar

Correct answer by
Community Advisor