on 02-01-2012 2:45 AM
Hi experts,
I have a Web Dynpro java application which requires me to set a default value to the DropDownByKey element. Currently the lead selection of the element is an empty string, so I would like to know how to set the default value to the first non-empty value in the list.
Any code snippet will be helpful.
Thanks,
Ju Lian
you should initialize attribute that mapped on selected key value of DropDownByKey - with default value
for example
property Key Value of DropDownByKey is mapped on attribute context Key
so
in wdDoInit you should write:
wdContext.currentContextElement.setKey(<default value>);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ju Lian,
As the value list is populated at runtime, you can try below.
Create one context attribute (SUB_TYPE) which will hold the data. And create one simple dictionary type object(SUB_TYPE) without any value in enumeration tab and assign this as a type to the context attribute(SUB_TYPE).
In the coding area write the below code to generate the list with runtime data
IWDAttributeInfo attributeInfo = wdContext.getNodeInfo().getAttribute(IPrivateTestView.IContextElement.SUB_TYPE);
ISimpleTypeModifiable subType = attributeInfo.getModifiableSimpleType();
subType.setFieldLabel("Test Fields");
subType.setDefaultValue(wdContext.currentContextElement().getAtt1())
IModifiableSimpleValueSet valueSet = subType.getSVServices().getModifiableSimpleValueSet();
valueSet.clear();
valueSet.put(wdContext.currentContextElement().getAtt2(), wdContext.currentContextElement().getAtt2_1());
valueSet.put(wdContext.currentContextElement().getAtt3(), (wdContext.currentContextElement().getAtt4());
The default value will be the Att1 . Organize imports for missing imports.
Thanks
Shankha
Edited by: Shankha_Saha on Feb 1, 2012 8:03 AM
hi
if you are doing svs for an attibute dynamically that is run time , then to set the DDBykey To first value by default is simple as shown
IWDAttributeInfo attributeInfo = wdContext.nodeVnOrderList().getNodeInfo().getAttribute(IPrivateSlsOrdListView.IVnOrderListElement.VA_I__STATUS);
ISimpleType simpleType = attributeInfo.getSimpleType();
ISimpleValueSet valueset = simpleType.getSVServices().getValues();
//Object key = element.getAttributeValue(attributeName);
if(valueset.size() > 0)
{
wdContext.currentVnOrderListElement().setVaI_Status(valueset.getKey(0).toString());
}
in the above code the status is the attribute for which the svs is done and it is binded to DDBKey ul element
and rest all u can understand from the code.......
Dear Ju Lian,
When you populate the DropDownByKey, you will use like :-
//CODE FOR POPULATING DATA FOR DropDownByKey
IWDAttributeInfo attributeInfo = wdContext.node<NODE NAME123>().getNodeInfo().getAttribute("<ATTRIBUTE123>");
ISimpleTypeModifiable var = attributeInfo.getModifiableSimpleType();
svs = var.getSVServices().getModifiableSimpleValueSet();
svs.clear();
svs.put("0".toString(), "Select".toString());
if(list.size()==0){
wdComponentAPI.getMessageManager().reportException("No Data Available.",true);
}else{
for(int i=0;i<<DYNAMIC NODE>.size();i++){
svs.put(<DYNAMIC KEY>, <DYNAMIC VALUE>);
}
}
//CODE FOR DEFULT VALUE SETTING FOR DropDownByKey
IWDAttributeInfo nodeInfo = wdContext.node<NODE NAME123>().getNodeInfo().getAttribute("<ATTRIBUTE123>");
ISimpleType simpleType = nodeInfo.getSimpleType();
ISimpleValueSet valueSet = simpleType.getSVServices().getValues();
wdContext.current<NODE NAME123>Element().set<ATTRIBUTE123>(valueSet.getText(valueSet.getKey(0).toString()));
Hope it will resolve your issue.
Best Regards
Arun Jaiswal
Hi,
Set the attirbute value to one of the values present in the value set and it will come as default in the dropdown.
These links may be helpful
http://help.sap.com/saphelp_nw70/helpdata/en/bb/69b441b0133531e10000000a155106/content.htm
Forum
http://forums.sdn.sap.com/thread.jspa?threadID=1863848
Thanks,
Jyothi.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi
if you are doing svs for an attibute dynamically that is run time , then to set the DDBykey To first value by default is simple as shown
IWDAttributeInfo attributeInfo = wdContext.nodeVnOrderList().getNodeInfo().getAttribute(IPrivateSlsOrdListView.IVnOrderListElement.VA_I__STATUS);
ISimpleType simpleType = attributeInfo.getSimpleType();
ISimpleValueSet valueset = simpleType.getSVServices().getValues();
//Object key = element.getAttributeValue(attributeName);
if(valueset.size() > 0)
{
wdContext.currentVnOrderListElement().setVaI_Status(valueset.getKey(0).toString());
}
in the above code the status is the attribute for which the svs is done and it is binded to DDBKey ul element
and rest all u can understand from the code.......
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.