Skip to Content
0
Former Member
Sep 21, 2005 at 11:43 AM

dynamic DropDownByKey

50 Views

Hello all,

I want to create dynamically a DropDownByKey and bind a list (dynamically) to it.

In standard doInit methods I added the following code :

IWDNodeInfo ddlNode = wdContext.getNodeInfo().addChild("DynamicDDLNode",null,true,true,false,false,false,true,null,null,null);

ddlNode.addAttribute("ddlKey" , "ddic:com.sap.dictionary.string");

ISimpleTypeModifiable myType= ddlNode.getContext().getModifiableTypeOf("DynamicDDLNode");

//ISimpleTypeModifiable myType=wdThis.wdGetAPI().getContext().getModifiableTypeOf("DynamicDDLNode");

IModifiableSimpleValueSet values=myType.getSVServices().getModifiableSimpleValueSet();

values.put("0","January");

values.put("1","February");

values.put("2","March");

values.put("3","April");

values.put("4","May");

values.put("5","June");

values.put("6","July");

values.put("7","August");

values.put("8","September");

values.put("9","October");

values.put("10","November");

values.put("11","December");

I have got "java.lang.ClassCastException" on

ISimpleTypeModifiable myType= ddlNode.getContext().getModifiableTypeOf("DynamicDDLNode");

I added also the following code to wdDoModifyView method:

IWDTransparentContainer container =(IWDTransparentContainer)view.getElement("RootUIElementContainer");

IWDDropDownByKey theDropDown = (IWDDropDownByKey) view.createElement(IWDDropDownByKey.class,"ddlByKey" );

theDropDown.bindSelectedKey("DynamicNode.ddlKey);

theDropDown.setWidth("4");

theDropDown.setVisible(WDVisibility.VISIBLE);

container.addChild(theDropDown);

Could you please guide me how to create correctly a DropDownByKey at run time ?

Thanks ahead