cancel
Showing results for 
Search instead for 
Did you mean: 

How to add a new enumeration value into simple type dictionary dynamically

Former Member
0 Kudos

Hi,

I am facing a problem..

I used a simple type local dictionary and added enumeration values in to that to populate a dropdownby key

Now i want to add a new enumeration value into the dropdown dynamically as entered in the input field..

For that i used AttributeInfo and simplemodifiable type to add a valuset to the attribute but since there is one another dropdown that is populated from one another attribute but of the same type of the simple type dictionary..

i want to add new enumeration into simple type dictionary so that all the dropdowns available from that type should be modified accordingly

If anyone knows how to do that plz send me..

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi ,

Use the code below to add values to simple type dynamically.

IWDAttributeInfo attributeInfo = wdContext.getNodeInfo().getAttribute(<Name>);
ISimpleTypeModifiable simpleType = attributeInfo.getModifiableSimpleType();
IModifiableSimpleValueSet valueSet = simpleType.getSVServices().getModifiableSimpleValueSet();
valueSet.put(<key>,<value>);

Regards,

Sunitha Hari

Answers (2)

Answers (2)

Former Member
0 Kudos

USed IModifiableSimpleValueSet to add values in simple type

Former Member
0 Kudos

You can try writing your own implementation for ISimpleValueServices interface. It works fine for static value set, maybe it will work properly with dinamically changable value sets.

Please refer to following examples.

Simple value services implementation class:


public class MyDictionaryValueServices implements ISimpleValueServices {
	private final Locale locale;
	private SimpleValueSet valueSet;

	public MyDictionaryValueServices(final Locale locale) {
		this.locale = locale;
		// Here you can provide value set initialization
	}

	public Locale getLocale() {
		return locale;
	}

	public IModifiableSimpleValueSet getModifiableSimpleValueSet() {
		final ModifiableSimpleValueSet modifiable = new ModifiableSimpleValueSet(locale);
		modifiable.putAll(valueSet);
		return modifiable;
	}

	public ISimpleValueSet getValues() {
		return valueSet;
	}

	public ISimpleValueSet getValues(Locale l) {
		return valueSet;
	}

	public boolean validate(Object value) {
		return valueSet.containsKey(value);
	}

	public boolean validate(String value) {
		return valueSet.containsKey(value);
	}

	// Method for dynamic value set modification
	public void addValue(String key, String value) {
		valueSet.put(key, value);
	}

There must be single intance of MyDictionaryValueServices. You can store it, for example, in context of componenet controller. Consider method getMyDictionaryValueServices that returns this single instance of MyDictionaryValueServices class.

For every attribute of your simple type you must set it's value services:


final IWDAttributeInfo attrInfo = ...;
attrInfo.getModifiableSimpleType().setSVServices(getMyDictionaryValueServices());

Adding new value into value set:


getMyDictionaryValueServices().addValue("NEW", "New value");