cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with RadioButtonGroupByIndex

Former Member
0 Kudos

Hello guys,

I created a Simple Type Enumeration with two values: 0 (Yes) and 1 (No).

In my view, I created a Context Attribute of this Type, and I created a RadioButtonGroupByIndex too (because I need the descriptions and not values only).

In Texts Property for RadioButtonGroupByIndex, I choise the Context Attribute.

The problem: When I run the application, only one RadioButton is visible and without description.

Any idea? Can you help me?

Thanks!

Kleber

Accepted Solutions (1)

Accepted Solutions (1)

former_member197348
Active Contributor
0 Kudos

Hi Kleber,

For DDIC type attributes you must use RadioButtonGroupByKey. Your problem can be solved in two ways.

1. If you want to use RadioButtonGroupByIndex , create a node with two attributes (say key value).

In wdDoInit(),

add this code,

IPrivate<Viewname>.I<nodename>Element ele1 = wdContext.create<nodename>Element();
ele1.setKey("0");
ele1.setValue("Yes");
wdContext.node<nodename>().addElement(ele1);  
 IPrivate<Viewname>.I<nodename>Element ele2 = wdContext.create<nodename>Element();
ele2.setKey("1");
ele2.setValue("No");
wdContext.node<nodename>().addElement(ele2);

Now bind texts Property of RadioButtonGroupByIndex to the attribute value

2. If you want to use RadioButtonGroupByKey, set the simple type value & description both to "Yes" (for enumeration 1) "No" (for enumeration 2).

Now you can see Yes, No in the output.

regards,

Siva

Answers (2)

Answers (2)

Former Member
0 Kudos

Hey guys!

Thanks a lot! Thank you very very much!!

Kleber

Former Member
0 Kudos

Hi expert,

Firstly you have to innsert radiobuttonGropbyindex in your view and create one context Node and attribute in your Component controller and mapping into the VIEW through the open DataModeler.

Suppose --

Context value Node---Radio

Context value attribute--Yes and Val.

afterdoing this thing binding yes Attribute into your texts property of RadiobuttongroupByindex .

write some code in wdDoInit()

public void wdDoInit()

{

//@@begin wdDoInit()

IPrivateCompView.IRedioElement rd=wdContext.nodeRedio().createRedioElement();

rd.setYes("yes");

rd.setVal("1");

wdContext.nodeRedio().addElement(rd);

rd=wdContext.nodeRedio().createRedioElement();

rd.setYes("No");

rd.setVal("0");

wdContext.nodeRedio().addElement(rd);

}

just check the if you click the any radio button either Yes or No.then it will fetching coresponding value as 0 or 1.

just craeted one eventmethod

set into the OnSelect property of radionButtongroupbyindex then it will show the appropriate valueas

public void onActionshow(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

msg.reportSuccess("show"+wdContext.currentRedioElement().getVal());

}

Thanks

Jati