on 12-28-2006 1:51 PM
Hi all,
I am getting a List from the database and I wish to populate a dropdownbykey element in webdynpro with this list. What is the correct method to do this? I have tried setting the dropdown from the context, but this did not help.
Please suggest some solution.
Thanks,
Mayuri
Hi Mayuri,
Do the following
1. Create a value attribute(say myValues) of type String in view Context
2. Bind myValues to the value property of DDByKey
3. After the code for getting the values from DB, add the following code
IWDAttributeInfo atInfo=wdContext.getNodeInfo().getAttribute(IPrivate<ViewName>.IContextElement.MY_VALUES);
ISimpleTypeModifiable stm=atInfo.getModifiableSimpleType();
IModifiableSimpleValueSet svs=stm.getSVServices(). getModifiableSimpleValueSet();
svs.put("KEY1","VALUE1 FROM ResultSet");
svs.put("KEY2","VALUE2 FROM ResultSet");
svs.put("KEY3","VALUE3 FROM ResultSet");
Thanks
Fahad Hamsa
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Create one context attribute and write the following code and make the changes as per your requirement.
IWDAttributeInfo valueInfo = wdContext.getNodeInfo().getAttribute(IPrivateControlPanelView.IContextElement.NAME);
ISimpleTypeModifiable valueType = valueInfo.getModifiableSimpleType();
// Set field label and populate valueset
valueType.setFieldLabel("Name");
// create a method with arraylist as the return type in your controller
ArrayList list = wdThis.wdGetController.getList ();
IModifiableSimpleValueSet valueSet = valueType.getSVServices().getModifiableSimpleValueSet();
if( list != null ) {
for (int index = 0 ; index < list.size() ; index ++ ) {
HashMap row = new HashMap();
if (row != null){
row = (HashMap) shiptoList.get(index);
keyValue = row.get ("KEY_VALUE");
keyName = row.get ("KEY_NAME");
valueSet.put (keyValue, keyName);
}
}
// in getList method of your controleler write the following code.
public ArrayList getList () {
ArrayList list = new ArrayList ();
while (rs.next ()) {
Map row = new HashMap ();
row.put ("KEY_NAME", rs.getString(1));
row.put ("KEY_VALUE", rs.getString (2));
// add row data to the arraylist
list.add (row);
}
return list;
}
Regards
Suresh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.