Skip to Content
0
Former Member
Aug 14, 2006 at 08:13 AM

Problem with adding allowed values to the property

10 Views

Hello,

I have a problem with adding allowed values to the property from code.

The problem is that the values are being added (they can

be seen for example on the miscellaneous tab of the

details of a text file), but they are not visible in

properties (Global services...PropertyStructures etc).

Regards,

Ladislav

PS. Below is the code which I use.

  public void AddValueToAllowedList( java.lang.String propValue )
  {
    //@@begin AddPropertyToAllowedList()

    try
    {
    	IPropertyConfigurationService propConfigService =
          (IPropertyConfigurationService) ResourceFactory.getInstance().getServiceFactory().
               getService("PropertyConfigurationService");

			
	IMetaModel metaModel = propConfigService.getMetaModel();
	
        // property namespace	
	String namespace = wdContext.currentPropertiesElement().getPropertyNamespace();
        // property name
	String name = wdContext.currentPropertiesElement().getPropertyName();
		
	IPropertyName propertyName = new PropertyName(namespace, name);
		
	IMetaName metaName = metaModel.searchByPropertyName(propertyName);

        // new value
	IMetaValue metaValue = metaModel.createMetaValue(metaModel, metaName, 
		new DefaultMetadataExtension(metaModel), propValue);
		
	IMetaValueListIterator iterator = metaName.allowedValueIterator();
        // add to the end of the list
	while (iterator.hasNext()) 
	{
	     IMetaValue m = iterator.next();
	}
		
	iterator.add( metaValue );
    }
    catch (ResourceException e) 
    {
		
    }
    catch (PropertyConfigurationServiceException e)
    {
		
    }
    
    //@@end
  }