Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: How do we use site scoped configurations?
Another configuration question. We would like to use site scoping for configuring one of our applications. We've only used system scope previously, and are comfortable with how that works. The question is, if you create a site-scoped configuration, is there a site-specific UI? Otherwise, what's the point? I understand that site scope will override system scope and give you a default configuration for all sites, but how do you then customize the configuration for each site? Is it necessary to create your own UI in the site settings?
Follow up: I followed the directions in the tutorial (https://help.liferay.com/hc/en-us/articles/360028726152-Scoping-Configurations) but when I retrieve the configuration using a ConfigurationProvider the configuration object doesn't have any config data in it. Here is the relevant code:
@ExtendedObjectClassDefinition(category = "NASA", scope =
ExtendedObjectClassDefinition.Scope.GROUP)
@Meta.OCD(
id =
"gov.nasa.hq.cesheets.internal.configuration.CESheetsPortletConfiguration",
localization = "content/Language",
name = "CE Sheets Portlet Configuration")
public
interface CESheetsPortletConfiguration {
...
public class CESheetsGroupConfigurationBeanDeclaration implements ConfigurationBeanDeclaration {
@Override
public Class<?>
getConfigurationBeanClass() {
return CESheetsPortletConfiguration.class;
}
}
...
@Component(
configurationPid =
"gov.nasa.hq.cesheets.internal.configuration.CESheetsPortletConfiguration",
configurationPolicy = ConfigurationPolicy.OPTIONAL,
immediate = true,
property = {
"javax.portlet.name=" + CESheetsPortletKeys.CESHEETS
},
service = ConfigurationAction.class)
public class CESheetsPortletConfigurationAction extends
DefaultConfigurationAction {
private static final Log _log =
LogFactoryUtil.getLog(CESheetsPortletConfigurationAction.class);
private volatile CESheetsPortletConfiguration
_configuration;
private static final String GRID_CONFIG_DATA
= "ROWDATA";
private ConfigurationProvider _configurationProvider;
@Reference(unbind = "-")
protected void
setConfigurationProvider(ConfigurationProvider configurationProvider)
{
System.out.println("HERE CONFIG
ACTION");
_configurationProvider =
configurationProvider;
}
...
try {
_configuration =
_configurationProvider.getGroupConfiguration(CESheetsPortletConfiguration.class,
groupId);
} catch (ConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String[] states = _configuration.workflowStates();
...
Here, the "states" array is empty although it is configured in the control panel (both system and instance settings). Previously, using SYSTEM scope, it worked fine.
Hi Steve, you've tagged your post with both 7.2 and 7.4 so I'll answer for 7.4. Setting the scope to GROUP in 7.4 gets you an autoo-generated UI in the Product Menu > Confioguration > Site Settings panel. For example, I just confirmed with the project linked to this documentation, by changing its scope to GROUP.
If I recall correctly the only thing you get in 7.2 is that the configuration entry in System Settings is labeld as Site-scoped, but you're responsible for creating the UI for the configuration.
Thanks Russell. We're currently on 7.2 but starting the process of going to 7.4 so that's good to know. We might just stick with system scope for now and then implement site scope when we go to 7.4.
Powered by Liferay™