on 08-16-2006 1:07 PM
Hi,
Is it possible to add allowed value for a defined property from code? And how can I do that? Its easy to get allowed values from code, but its not so easy to add allowed values.
The following piece of code does exactly that, but its not working when the allowed value list is empty (allowed values are not being added).
try
{
IPropertyConfigurationService propConfigService =
(IPropertyConfigurationService) ResourceFactory.getInstance().
getServiceFactory().getService("PropertyConfigurationService");
IMetaModel metaModel = propConfigService.getMetaModel();
String namespace = wdContext.currentPropertiesElement().getPropertyNamespace();
String name = wdContext.currentPropertiesElement().getPropertyName();
IPropertyName propertyName = new PropertyName(namespace, name);
IMetaName metaName = metaModel.searchByPropertyName(propertyName);
IMetaValue metaValue = metaModel.createMetaValue(metaModel, metaName,
new DefaultMetadataExtension(metaModel), propValue);
IMetaValueListIterator iterator = metaName.allowedValueIterator();
while (iterator.hasNext())
{
iterator.next();
}
iterator.add( metaValue );
}
catch (ResourceException e)
{
MessageManager msgMgr = (MessageManager)wdComponentAPI.getMessageManager();
msgMgr.reportWarning(e.toString());
}
catch (PropertyConfigurationServiceException e)
{
MessageManager msgMgr = (MessageManager)wdComponentAPI.getMessageManager();
msgMgr.reportWarning(e.toString());
}
Am I doing something wrong? Is there another way to accomplish this? Maybe somebody has had the similar problem like this?
Hi Ladislav,
DefaultMetadataExtension implements IDynamicValues. IMetaValueList IDynamicValues.getAllowedValues().
IMetaValueList.add(IMetaValue element).
Best regards, Maksim Rashchynski.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.