on 07-30-2008 2:36 PM
I have a Simple Type that has numerical values and text descriptions. It is bound to a dropdownbykey box. I am using this code to retrieve the users selection:
String sField = wdThis.wdGetApplicationController().wdGetContext().currentContextElement().getFields();
This returns the value (e.g., 1 or 2) which is great because I need this index to send to the database, however I would also like to display the description(e.g., blue or green) for the user so they can be reminded of their selection.
What is the best way to retrieve the description for the selected item?
First, this can be simplified by using context mapping: Map the attribute "fields" from the view controller to the component controller. Then you can just write
String sField = wdContext.currentContextElement().getFields();
To get the description from the value, you have to access the value set defined for the simple type. Something like
ISimpleValueSet valueSet = wdContext.getNodeInfo().getAttribute(IContextElement.FIELDS)
.getSimpleType().getSVServices().getValues();
String description = valueSet.getText(value, WDClientUser.getCurrentUser().getLocale() );
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>
> To get the description from the value, you have to access the value set defined for the simple type. Something like
>
> ISimpleValueSet valueSet = wdContext.getNodeInfo().getAttribute(IContextElement.FIELDS) > .getSimpleType().getSVServices().getValues(); > String description = valueSet.getText(value, WDClientUser.getCurrentUser().getLocale() ); >
>
> Armin
I see what you are saying here and I hate to sound simple but I don't understand where the ISimpleValueSet and IContextElement are coming from...
I get an error saying cannot be resolved or is not a type. Is this something you defined earlier or am I missing an import statement somewhere?
Hi,
In drop down by key, you will store values as (key, value) pair. presently you are retrieving key. same way retrieve the value.
hope you have drop down key value pair as (1,blue), (2,red)......
in your same code String sField = wdThis.wdGetApplicationController().wdGetContext().currentContextElement().get<VALUES>();
PradeeP
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Pradeep but I don't understand:
Fields is the name of my simple type so when I said
String sField = wdThis.wdGetApplicationController().wdGetContext().currentContextElement().getFields();
getFields returns the value of Simple Type Fields.
I am trying to return the description - as you said I have it set up as (1,blue) and (2,green). Your replay stated to use:
String sField = wdThis.wdGetApplicationController().wdGetContext().currentContextElement().get<VALUES>();
What does <VALUES> stand for?
Hi,
This is my code to populate the drop down by key
IWDAttributeInfo pColorAttInfo=wdContext.nodePstatus_out().getNodeInfo().getAttribute("color");
ISimpleTypeModifiable pColorSMT= pStatAttInfo.getModifiableSimpleType();
IModifiableSimpleValueSet pColorSimpValSet= pColorSMT.getSVServices().getModifiableSimpleValueSet();
//hard coding the drop down values
pColorSimpValSet.put(1,blue);
pColorSimpValSet.put(2,red);
pColorSimpValSet.put(3,green);
}
In the above code (1,blue), (2,red)... is (key, value).
i.e. you are storing as valueset.put ( key, value).
when retrieving pass the key it will display the value. i.e in my code it will give you value like blue,red....
PradeeP
Edited by: pradeep bondla on Jul 30, 2008 4:40 PM
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.