cancel
Showing results for 
Search instead for 
Did you mean: 

dynamic DropDownByKey

Former Member
0 Kudos
104

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Yoel,

In your code, instead of

<b>

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

ISimpleTypeModifiable myType= ddlNode.getContext().getModifiableTypeOf("DynamicDDLNode");</b>

write

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

ISimpleTypeModifiable myType= info.getModifiableSimpleType();

And instead of

<b>theDropDown.bindSelectedKey("DynamicNode.ddlKey);</b>

write

theDropDown.bindSelectedKey("DynamicDDLNode.ddlKey");

Also, increasing the size of the dropdown from "4" would make it properly visible, eg:

theDropDown.setWidth("60");

Best regards,

Nibu.

Message was edited by: Nibu Wilson

Former Member
0 Kudos

Thank you,

It is working

Former Member
0 Kudos

Yoel,

It would be very encouraging if you could close the thread by awarding points for 'Problem Solved'.

Best regards,

Nibu.

Answers (0)