May 13, 2020
Estimated Post Reading Time ~

Select Default Values in Selection Box in CQ5 Dialogs

During project development, I was facing an issue

“how to select a default value in Selection box (Combobox or Dropdown) or in checkbox group where option fields are static or dynamically generated.”

Solution
For Selection Box(dropdown or Combobox) having static option values or dynamically generated options values, declare two properties.

  1. defaultValue
  2. value

Note: defaultValue is a prerequisite & option selection will take place using value property.

Set these properties as shown below –



Points to be remember
1. defaultValue property could be of type String or String[]. For default value selection you have to declare this property. It depends on your requirement. ex. String[] for checkbox, String for combobox.
If you don’t declare this property and add only value property then option selection doesn’t take place.

2. value property could also be type String or String[]. It’s only requirement is you have declared defaultValue property.

3. there is no need to define any value in defaultValue property just leave it empty but define.

4. selection of default options will take place on the basis of value property.

For a Selection Box (Combobox)
1. defaultValue should of type String &
2. value should also be type String as only one value could be selected at one time.

For a CheckBox
1. defaultValue could be of type String or String[]. and it may or may not have values.
2. value Should be of type String[] as you may want to select multiple checkboxes at the time of loading.


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.