Scoping Configurations

In Liferay DXP, you can set an application’s configuration to different levels of scope: System, Instance, Site, or Portlet. For example, if you create an application to have instance scoped configuration, the application can be independently configured for each instance you have set up in your Liferay DXP installation. This is useful because it gives more flexibility and control to each user. For example administrators of a DXP instance can set a configuration for their own instance that is independent from other instances.

To learn more about scope, see Understanding Configuration Scope.

To see an example of an instance scoped configuration, see the example portlet from Setting and Accessing Configurations

Note, portlet scoped configuration takes a different approach. See Portlet Level Configuration for more information.

Specify Scope in the Configuration Interface

To set the scope of a configuration, specify the scope in the configuration interface. Use the @ExtendedObjectClassDefinition annotation to set your scope. Use Scope.SYSTEM for system scope. Use Scope.COMPANY for instance scope. Use Scope.GROUP for site scope.

@ExtendedObjectClassDefinition(
	category = "n2f3", scope = ExtendedObjectClassDefinition.Scope.COMPANY
)

Use the Configuration Provider

To retrieve the configuration, make use of ConfigurationProvider. The Configuration Provider API provides an easy way to access the configuration. Choose the specific method for your application needs:

  • getSystemConfiguration(): Obtains system-scoped configuration. The application’s system level configuration is found in Control PanelConfigurationSystem Settings.

  • getCompanyConfiguration(): Obtains instance-scoped configuration. Use an instance of Portal to retrieve companyId. For example, _portal.getCompanyId(renderRequest). The application’s instance level configuration is found in Control PanelConfigurationInstance Settings.

  • getGroupConfiguration(): Gets Site-scoped configuration. Use an instance of Portal to retrieve groupId. For example, _portal.getScopeGroupId(renderRequest). The application’s Site level configuration is found in Product MenuConfigurationSite Settings. Note, this is available in Liferay 7.4.

For portlet scoped configuration see Portlet Level Configuration.

Capabilities

Product

Contact Us

Connect

Powered by Liferay
© 2024 Liferay Inc. All Rights Reserved • Privacy Policy