Difference between revisions of "Documentation/DevGuide/Config/Using a Data Source"
From Apache OpenOffice Wiki
< Documentation | DevGuide
(Initial author Sun Microsystems, Inc.) |
|||
| (7 intermediate revisions by 5 users not shown) | |||
| Line 5: | Line 5: | ||
|NextPage=Documentation/DevGuide/Config/Reading Configuration Data | |NextPage=Documentation/DevGuide/Config/Reading Configuration Data | ||
}} | }} | ||
| − | {{DISPLAYTITLE:Using a Data Source}} | + | {{Documentation/DevGuideLanguages|Documentation/DevGuide/Config/{{SUBPAGENAME}}}} |
| − | After a configuration provider is obtained, call | + | {{DISPLAYTITLE:Using a Data Source}} |
| + | After a configuration provider is obtained, call <idlm>com.sun.star.lang.XMultiServiceFactory:createInstanceWithArguments</idlm>() to create a view on the configuration data. | ||
The following arguments can be specified when creating a view: | The following arguments can be specified when creating a view: | ||
| Line 28: | Line 29: | ||
(or "<code>*</code>") | (or "<code>*</code>") | ||
|Using this parameter, specify the locale to be used for selecting locale-dependent values. Use the ISO code for a locale, for example, en-US for U.S. English. | |Using this parameter, specify the locale to be used for selecting locale-dependent values. Use the ISO code for a locale, for example, en-US for U.S. English. | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
|} | |} | ||
| − | {{ | + | {{Note|If the special value "<tt>*</tt>" is used for the <tt>locale</tt> parameter, values for all locales are retrieved. In this case, a locale-dependent property appears as a set item. The items of the set are the values for the different locales. They will have the ISO identifiers of the locales as names. |
| − | + | It can be used if you want to assign values for different locales in a targeted manner.}} | |
| − | |||
| − | It can be used if you want to assign values for different locales in a targeted manner | ||
To create a read-only view on the data, the service <idl>com.sun.star.configuration.ConfigurationAccess</idl> is requested: | To create a read-only view on the data, the service <idl>com.sun.star.configuration.ConfigurationAccess</idl> is requested: | ||
| − | + | <syntaxhighlight lang="java"> | |
// Create a specified read-only configuration view | // Create a specified read-only configuration view | ||
public Object createConfigurationView(String sPath) throws com.sun.star.uno.Exception { | public Object createConfigurationView(String sPath) throws com.sun.star.uno.Exception { | ||
| Line 74: | Line 58: | ||
return xViewRoot; | return xViewRoot; | ||
} | } | ||
| + | </syntaxhighlight> | ||
| + | To obtain updatable access, the service <idl>com.sun.star.configuration.ConfigurationUpdateAccess</idl> is requested. | ||
| − | + | {{PDL1}} | |
| − | + | [[Category:Documentation/Developer's Guide/Configuration Management]] | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Latest revision as of 17:01, 21 December 2020
After a configuration provider is obtained, call createInstanceWithArguments() to create a view on the configuration data.
The following arguments can be specified when creating a view:
| Parameter Name | Type | Default | Comments |
|---|---|---|---|
nodepath
|
string
|
- | This parameter is required. It contains an absolute path to the root node of the view. |
Locale
|
string
|
The user's locale
(or " |
Using this parameter, specify the locale to be used for selecting locale-dependent values. Use the ISO code for a locale, for example, en-US for U.S. English. |
To create a read-only view on the data, the service com.sun.star.configuration.ConfigurationAccess is requested:
// Create a specified read-only configuration view
public Object createConfigurationView(String sPath) throws com.sun.star.uno.Exception {
// get the provider to use
XMultiServiceFactory xProvider = getProvider();
// The service name: Need only read access:
final String sReadOnlyView = "com.sun.star.configuration.ConfigurationAccess";
// creation arguments: nodepath
com.sun.star.beans.PropertyValue aPathArgument = new com.sun.star.beans.PropertyValue();
aPathArgument.Name = "nodepath";
aPathArgument.Value = sPath;
Object[] aArguments = new Object[1];
aArguments[0] = aPathArgument;
// create the view
Object xViewRoot = xProvider.createInstanceWithArguments(sReadOnlyView, aArguments);
return xViewRoot;
}
To obtain updatable access, the service com.sun.star.configuration.ConfigurationUpdateAccess is requested.
| Content on this page is licensed under the Public Documentation License (PDL). |