April 3, 2020
Estimated Post Reading Time ~

Checkboxes OSGi property via run modes/ Setup checkboxes for OSGi

If you want to create checkboxes for your OSGI properties then you can do it by having boolValue attribute assigned to Property annotation.

@Property(boolValue = false/true)
public static final String XYZ_PROPERTY = “xyz.property”;

private boolean xyz;

Retrieving these properties is also simple, you can simply do it like this

@Activate
public void activate(final Map<String, String> properties) {

this.xyz = PropertiesUtil.toBoolean(properties.get(XYZ_PROPERTY ), false);

}


But sometimes you will run into situations where you would need to override these values from OSGI config. If you remove the boolValue from property annotation then the property will be treated as String instead of Boolean.

Example: you want checkbox checked for this above property from OSGI and you somehow don’t want to do it via code because this might change for environments

In your run mode file, if you have the below property and boolValue within the property annotation in the code, you are sorted.

xyz.property=”{Boolean}true”



By aem4beginner

No comments:

Post a Comment

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