on 11-03-2008 5:55 AM
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..
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
USed IModifiableSimpleValueSet to add values in simple type
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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");
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.