cancel
Showing results for 
Search instead for 
Did you mean: 

Reg: Dynamic creation of UI elements

Former Member
0 Kudos

Hi,

I need to create radio button group and dropdown dynamically in my application. Kindly suggest me the steps.

Regards,

Becky.

Accepted Solutions (1)

Accepted Solutions (1)

former_member192434
Active Contributor
0 Kudos

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi,

Thank you all for the quick responses.

While creating a radio button do we need to create new context for it?

And also the drop down which i have to create, there is an application which already contains buttons containing different actions, but i need to modify it and change it to a drop down list containing different values which were earlier performed through buttons. What all do i need to change in this. What will be teh changes in the context to be made?

Please explain.

Thanks n Regards,

Becky.

Former Member
0 Kudos

Hi Joseph,

For radio button, if you like then create context same as you have done for dropdown otherwise you just create an enum and bind the properties of radio button.

You can use existing event with dropdown but in this scenario you have to bind event dynamically.

Like :--

IWDAction theAction = wdThis.wdCreateAction(

IPrivateDynamicView.WDActionEventHandler

.GENERIC_ACTION,

"");

theButton.setOnAction(theAction);

theButton.mappingOfOnAction().addParameter(

"Command",op.getName());

theActionContainer.addChild(theButton);

Kind Regards

Sarsij

Former Member
0 Kudos

Hi Joseph,

Please find code to create dynamacally drop-down.

List<ConfigFieldStructureDTO> fieldValuesList = cfgParamDTO.getParamValuesList();

IWDDropDownByKey fieldDescDropDown = (IWDDropDownByKey)view.createElement(IWDDropDownByKey.class, "descDropDown_"+cfgParamDTO.getConfigParamId());

IDataType dataType = wdContext.nodeFieldData().getNodeInfo().getAttribute("defaultdataType").getDataType();

IWDAttributeInfo attr = wdContext.nodeFieldData().getNodeInfo().addAttribute("FieldDescDropDownType"+cfgParamDTO.getConfigParamId(), dataType);

IModifiableSimpleValueSet<String> set = wdContext.nodeFieldData().getNodeInfo().getAttribute(attr.getName()).getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();

Iterator<ConfigFieldStructureDTO> cfgStructIter = fieldValuesList.iterator();

while(cfgStructIter.hasNext())

{

ConfigFieldStructureDTO cfgStructureDTO = cfgStructIter.next();

String value = cfgStructureDTO.getFieldValue();

boolean selected = cfgStructureDTO.isSelected();

set.put(value,value);

if(selected==true)

{

wdContext.currentFieldDataElement().setAttributeValue(attr.getName(),value);

}

}

fieldDescDropDown.setWidth("28%");

fieldDescDropDown.bindSelectedKey(wdContext.nodeFieldData().getNodeInfo().getAttribute(attr.getName()));

Here defaultdataType I have created a blank context of type String.

cfgParamDTO is a class from where I am getting data to populate dropdown.

Other part of code is straight forward.

If you have any concern please let me know.

Kind regards

Sarsij

Former Member
0 Kudos

Please give more details (use-case, context structure etc.)

Armin

Former Member
0 Kudos

>

> I need to create radio button group and dropdown dynamically in my application. Kindly suggest me the steps.

>

Hi,

Pls have a look -

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/74cda090-0201-0010-6b91-f85b2489...

Regards

Anagha

Former Member
0 Kudos

Hi,

You can go for the following links for Dynamic UI Creation.

http://help.sap.com/erp2005_ehp_03/helpdata/EN/4f/07cf3dd28b5610e10000000a114084/frameset.htm

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sapportals.km.docs/business_packages/a1-8...

To create a DropDownByIndex that displays the elements of node "Items" as its items, you write the following code in method wdDoModifyView():

IWDDropDownByIndex dd = (IWDDropDownByIndex) view.createElement(IWDDropDownByIndex.class, null);

dd.bindTexts("Items.Text");

IWDUIElementContainer parent = (IWDUIElementContainer) view.getElement("ID-of-parent");

parent.addChild(dd);

I hope the code and the links will help you a lot.

Thanx

former_member201361
Active Contributor
0 Kudos

Hi ,

In the domodifyView method ur View , create the Ui Element , which u want to display at runtime .

for eg :

IWDradioButton radio = view.createElemebnt()IWDRadioButtonb.class);

radio.set.....();

in this way , create drop down and bind the attribute to it .

hope it helps

Thanks and Regards

fazal