cancel
Showing results for 
Search instead for 
Did you mean: 

Value of the selectedKey of a radiobutton

Former Member
0 Kudos

Hi,

I have created two radiobuttons, "AuthorRadioButton" and "PublisherRadioButton". I bound their properties 'keyToSelect' to two different context attributes of type boolean (Author and Publisher) and the property 'selectedKey' to the same context attribute named 'SelectedKey' of type string.

Now I want to access at runtime to the value of this UI-Element. The value of the radiobutton should be available in the context attribute 'SelectedKey' or?

But I always get the string "true" if I access via wdContext.currentContextElement().getSelectedKey(). But I must also know which radiobutton this value belongs.

Has somebody any idea?

Thanks.

Cemal

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Cemal,

create 2 context attributes say att1 and att2 of string type

create an attribute sel of string type

Assign some values for att1 and att2 say "a" and "b" .assign "a" for sel if you want first one checked

kettoselect of first button should be bound to att1 and

kettoselect of second button should be bound to att2

selectedkey of both should be bound to sel.

.At runtime whatever value you select will come to sel

hope this helps you

If you query is solved close the post

Regards

Rohit

Former Member
0 Kudos

Hi,

after I changed the type of the attributes 'keyToSelect' to string and assigning them values, the value of the selected button is transfered now to the selectedKey - Attribute.

Thanks to all for your help.

Cemal

Former Member
0 Kudos

Hi Rohit,

i have similar problem, posted another thread

I followed similar procedure what you mentioned , i have a textedit UI element apart from two radio buttons, now if select first button text related to fist button should appear in text edit similarly for the second one , Actually this text i am reading from bapi on the other hand i will hardcode some text (sometext for button1 and similarly for button2) how to do this.

How can i proceed further...

Regards,

Murali

Former Member
0 Kudos

Hi Murali,

This is also in relation to the question posted by cemal salman.

As i see it you both have the same problem with a little difference.

Here is an example which hopefully should solve your problems :

Consider an application with 2 radiobuttons(R1 and R2) and a TextEdit UI -

1) Create 3 context elements bike,car and vehicle_sel

2) In R1 properties,assign

Keytoselect -> bike

Selectedkey -> vehicle_sel

and have an event Update() where u write this code -

wdContext.currentContextElement().getVehicle_sel();

3) In R2 properties,assign

Keytoselect -> car

Selectedkey -> vehicle_sel

Similarly set the Event to Update()

4) In TextEdit UI, assign

Value -> vehicle_sel

5) In doInit() you can have the following code which will set the text for the radio buttons-

wdContext.currentContextElement().setBike("BIKE");

wdContext.currentContextElement().setCar("CAR");

Hope this helps you.

Kindly give a feedback

Answers (2)

Answers (2)

Former Member
0 Kudos

HI,

lets assume that there r two radio buttons R1 and R2

create three attributes in context. R1,R2,sel.

for R1

key to select --R1

selected key ---sel

for R2

ket to selcet --R2

selected key ---sel

under implimentation ---initilize as

public void wdDoInit()

{

//@@begin wdDoInit()

wdContext.currentContextElement().setR1("Pass");

wdContext.currentContextElement().setR2("Fail");

wdContext.currentContextElement().setSel("Fail");

//@@end

}

so that by default R2 will be enabled and its value is false bce

wdContext.currentContextElement().setR2("Fail");

wdContext.currentContextElement().setSel("Fail");

If we select the R1 radio button during run time then the sel value will set to "True" automatically.

Hope u were satisfied.

Regards,

Krishnam Raju

if u select the R1 button then the

Former Member
0 Kudos

You don't need to bind the "keyToSelect" properties.

If buttonA.keyToSelect = "A" and buttonB.keyToSelect = "B", then you can select buttonA by setting the "selectedKey" context value to "A", similar for buttonB.

Armin

Former Member
0 Kudos

Hi Armin,

ok, if i want to select the buttons dynamically in the program.

But I want to handle user selections of the buttons and I want to know which button is selected!

Cemal

Former Member
0 Kudos

What's the problem?

Let S be the context attribute that stores the selected key (and to which you bound the "selectedKey" properties).

buttonA is selected <=> S == "A"

buttonB is selected <=> S == "B"

Armin