Using Required for system configurations.
How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!
While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.
legacy-article
learn-legacy-article-disclaimer-text
Issue
- We would like to add required = true configuration to our system configuration.
- Upon requesting the data through a groovy script the string returns empty when required = true is set.
Resolution
- Sadly this is currently a limitation of ConfigurationProviderUtil.getSystemConfiguration.
- However currently there is a feature request that aims to address this behavior.
- In case you definitely need the required = true properties, you should fetch the configuration by ConfigurableUtil like below:
@Component(
configurationPid = "com.custom.search.suggestion.conf.RBIDidYouMeanConfiguration",
service = TestComponent.class
)
public class TestComponent {
@Activate
@Modified
protected void activate(Map<String, Object> properties) {
_RBIDidYouMeanConfiguration = ConfigurableUtil.createConfigurable(
RBIDidYouMeanConfiguration.class, properties);
}
private volatile RBIDidYouMeanConfiguration
_RBIDidYouMeanConfiguration;
}
did-this-article-resolve-your-issue