Thursday, 26 June 2014

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, as I show in my last post, declare two properties.
  1. defaultValue
  2. value

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

Set these properties as show 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 checkbox at the time of loading.

Namah Shivay