cancel
Showing results for 
Search instead for 
Did you mean: 

selecting radio buttons.

Former Member
0 Kudos

hi,

i have two radio buttons.i need to pass some parameters so to inform as to which radio button is selected.Plz tell the code and way to display this.its liitle urgent

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You need add radioButtonGroupByKey to your view. Add a context attribute.

Create a simple type with two values:

Value: Description:

Y YES

N NO

Select this simple type as the type of your attribute.

Now map this attibute to the selectedKey property of your radioButtonGroupByKey. Now if YES is selected then the value of the attribute will be Y and for NO it will be N.

You can get the information about which radio button is selected using this attribute.

Hope this will solve your problem.

thanks & regards,

Manoj

Answers (2)

Answers (2)

former_member485701
Active Participant
0 Kudos

Hi Nisha,

First few information for radio button elemnt.

(1)The RadioButton UI element represents a two-state button.

(2)The property selectedKey must be bound to a context attribute, e.g. Key. The radio button is selected if the value of attribute Key equals the value of the property keyToSelect.

(3)On selection of the radio button, the action assigned to event onSelect is executed.

Now as I said above insert two radio buttons. And create one context attribute of string type "selectedKey", and bind it with both the radio button's selected key property.

and assign following names in the radio buttons keyToSelect properties

(a) radio1 (for 1st radio button)

(b) radio2 (for 2nd radio button)

And Go to properties of the radio button and create an action for onSelect for the radio button.

And for second radio button , assign the same onSelect action.

Now when you select any of the radio button, then do following operation in onSelect method.

String selectedKey=wdContext.currentContextElement().getSelectedKey();

if(selectedKey.equals("radio1")){

//do the needed operation

} if(selectedKey.equals("radio2")){

}

Feel free to ask questions

REgards,

Praveen

Former Member
0 Kudos

hi

i have writtne this code in onactionSelect action

String selectedKey=wdContext.currentContextElement().getVa_selectedkey();

if(wdContext.currentContextElement().getVa_selectedkey()=="KEY_0")

{

wdContext.currentVn_radioElement().setVa_formal(true);

//wdContext.currentVn_radioElement().setVa_streamline(false);

}

else

if(wdContext.currentContextElement().getVa_selectedkey()=="KEY_1")

{

//wdContext.currentVn_radioElement().setVa_formal(false);

wdContext.currentVn_radioElement().setVa_streamline(true);

}

where va_streamline and va_normal are set enabled property of each radio buttons.

and KEY_0and KEY_1 are are setto key to select property.

but the problem is at the run time radio buttons are getting disabled.what should be donee.plz helppp

former_member197348
Active Contributor
0 Kudos

Hi Nisha,

Are you sure wdContext.currentContextElement().getVa_selectedkey(); is returning right value. You can check the value by printing it once.

regards,

Siva

Former Member
0 Kudos

Hi...

try

if(wdContext.currentContextElement().getVa_selectedkey().equals("KEY_0"))

instead of

if(wdContext.currentContextElement().getVa_selectedkey()=="KEY_0")

Former Member
0 Kudos

thanks the problem is solved .

Former Member
0 Kudos

Hi,

Add a parameter to the onSelect action of the radio button.

map this parameter to the id of the radio buttons.

Ex:

In your WdModify

IWDRadioButton rb1 = (IWDRadioButton)view.getElement("<Your Radio Button1>");

IWDRadioButton rb2 = (IWDRadioButton)view.getElement("<Your Radio Button2>");

rb1.mappingOfOnSelect().addSourceMapping("selected", "ID");

rb2.mappingOfOnSelect().addSourceMapping("selected", "ID");

parameter selected should be of type string.

In the action handler write the corresponding code

if(selected.equals("Male")) // if the ID is Male

// Your code

else

// Your code

Regards

Ayyapparaj

Former Member
0 Kudos

sir,

Plz be a little bit clear iam not getting what to do.

Former Member
0 Kudos

Hi,

Create a generic onSelect event handler for both the radio buttons with a parameter of type string

Map this parameter to the ID of individual radio buttons.

When the radio button is selected this event will be called with different IDs.

Based on the ids you can perform different actions.

Regards

Ayyapparaj