cancel
Showing results for 
Search instead for 
Did you mean: 

RadioButtonbyKey

former_member1193316
Participant
0 Kudos

Hi,

I hav been wrote the following code in wddoinit method.

*data: lr_node_info type ref to if_wd_context_node_info,

  • lt_valueset type table of wdr_context_attr_value,

  • ls_valueset type wdr_context_attr_value,

  • lr_node type ref to if_wd_context_node.

*

*lr_node = wd_context->get_child_node( 'USER_GENERAL_INFO' ).

*lr_node_info = lr_node->get_node_info( ).

*

*

*clear: ls_valueset, lt_valueset.

*

*ls_valueset-value = 'key1'.

*ls_valueset-text = 'Male'.

*append ls_valueset to lt_valueset.

*

*ls_valueset-value = 'key2'.

*ls_valueset-text = 'Female'.

*append ls_valueset to lt_valueset.

*

*lr_node_info->set_attribute_value_set(

*exporting

*name = 'GENDER'

*value_set = lt_valueset ).

during runtime when i select radio button, its not selecting anything. still i need to write code at onaction button,. but i dont knw wat to wirte. could you guys please help me regarding this.

thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi.

when you want to do some action when user selects an entry:

create the action for the onSelect event.

In the action you get the context element of the currenty selected entry like:

Data:

lr_element type ref to if_wd_context_element,

. ls_valueset type wdr_context_attr_value

lr_element = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).

lr_element->get_static_attributes(

static_attributes = ls_valueset

).

Then you can do something with it.

If you want to have a button which perfroms some action regarding the current selection just craete an action for the button and in the action you can get the selected element like:

lr_node = wd_context->get_child_node( 'USER_GENERAL_INFO' ).

lr_element = lr_node->get_element( ).

lr_element->get_static_attributes(

static_attributes = ls_valueset

).

Hope this helps,

Sascha

mohammed_anzys
Contributor
0 Kudos

Hi

In the radio button properties , you have set the KeyToSelect attribute .According to that only the radio button will get enabled to disabled.

Thanks

Anzy

former_member1193316
Participant
0 Kudos

Hi guys,

i m really got confused by looking above thing.

please explain me propelry where to write.

wat i hav to write in "onselect" event and what to write on "button" action.

please tell me

thanks in advance

mohammed_anzys
Contributor
0 Kudos

Hi Venkat,

Dont get confused , first in the drop down properties you need to mention , the KeyToSelect .In My case i used 'X'.So whenever the value of the bound attribute is 'X' the radio button will be enabled.

Thanks

Anzy

mohammed_anzys
Contributor
0 Kudos

Hi

No need to get confused.Please put the property for the Radio Button .. i mean the selected Key...For example in my case , i put the Key as 'X'..so when the contex attribute is 'X' ..the radio button will be selected.Also ..when you click on the radio button , the value of the context attribute will be set with 'X'.

Also you could use the code provided by Nithya to fetch the selected value.

Thanks

Anzy

former_member1193316
Participant
0 Kudos

Hi Anzy,

I hav followed the same which u mentioned above like,

i hav wrote the following code in doinit

method WDDOINIT .

data: lr_node_info type ref to if_wd_context_node_info,

lt_valueset type table of wdr_context_attr_value,

ls_valueset type wdr_context_attr_value,

lr_node type ref to if_wd_context_node.

lr_node = wd_context->get_child_node( 'USER_GENERAL_INFO' ).

lr_node_info = lr_node->get_node_info( ).

clear: ls_valueset, lt_valueset.

ls_valueset-value = 'key1'.

ls_valueset-text = 'Male'.

append ls_valueset to lt_valueset.

ls_valueset-value = 'key2'.

ls_valueset-text = 'Female'.

append ls_valueset to lt_valueset.

lr_node_info->set_attribute_value_set(

exporting

name = 'GENDER'

value_set = lt_valueset ).

endmethod.

and i wrote the following code in "onselect" event for radiobutton

method ONACTIONRBUTTON .

data: lr_node type ref to if_wd_context_node,

lr_elem type ref to if_wd_context_element,

item_gender type zaccount-gender.

lr_node = wd_context->get_child_node( 'USER_GENERAL_INFO' ).

lr_elem = lr_node->get_element( ).

lr_elem->get_attribute(

exporting

name = 'GENDER'

importing

value = item_gender ).

endmethod.

even thogh its not working. wen i select the radio button, its not selecting.

wat to do

former_member1193316
Participant
0 Kudos

Hi,

I hav follwed the same which u mentioned.

i wrote the code for doinit, whcih i mentioned in my first thread.

i wrote the code "onselect" even for radio button as follow

method ONACTIONRBUTTON .

data: lr_node type ref to if_wd_context_node,

lr_elem type ref to if_wd_context_element,

item_gender type zaccount-gender.

lr_node = wd_context->get_child_node( 'USER_GENERAL_INFO' ).

lr_elem = lr_node->get_element( ).

lr_elem->get_attribute(

exporting

name = 'GENDER'

importing

value = item_gender ).

endmethod.

even though its not selecting the radio button when i select.

wat to do

mohammed_anzys
Contributor
0 Kudos

Hi Venkat,

I am compliin your code. Give me two minutes.

Thanks

Anzy

mohammed_anzys
Contributor
0 Kudos

Hi Venkat,

Its not working , i am debugging that .In the mean time you can look at WDR_TEST_EVENTS .In that there is an example for radio nbutton.You could use that methodology.

Thanks

Anzy

Award points for useful answers

former_member1193316
Participant
0 Kudos

Thanks Anzy, please find out n please let me knw. by the way, waht u hav provided this, it does not hav the coding how to implement it knw. i didnt felt that this is much useful for me

any wayz thanks for ur cooperation yar.

former_member1193316
Participant
0 Kudos

Now i m getting an error like

"Access via 'NULL' object reference not possible"

what does it mean

waht i need to change

Former Member
0 Kudos

Hi Venkat,

I have tried out the code that I have given and it works fine for me.

Your UI element in the view should be a <b>RadioButtonGroupByKey</b>, not simply a RadioButton. The <b>selectedKey</b> property should be bound to the context attribute 'Gender'. I hope you know how to do that binding.

Now, my exact code is this:

<b>method WDDOINIT .</b>

data: lr_node_info type ref to if_wd_context_node_info,

lt_valueset type table of wdr_context_attr_value,

ls_valueset type wdr_context_attr_value,

lr_node type ref to if_wd_context_node.

lr_node = wd_context->get_child_node( 'USER_GENERAL_INFO' ).

lr_node_info = lr_node->get_node_info( ).

clear: ls_valueset, lt_valueset.

ls_valueset-value = 'key1'.

ls_valueset-text = 'Male'.

append ls_valueset to lt_valueset.

ls_valueset-value = 'key2'.

ls_valueset-text = 'Female'.

append ls_valueset to lt_valueset.

lr_node_info->set_attribute_value_set(

exporting

name = 'GENDER'

value_set = lt_valueset ).

<b>endmethod.</b>

I have defined an event 'Select' for the onSelect action of the radio button. The code inside my onSelect is:

<b>method ONACTIONSELECT .</b>

data: lr_node type ref to if_wd_context_node,

lr_elem type ref to if_wd_context_element,

item_gender type char01.

lr_node = wd_context->get_child_node( 'USER_GENERAL_INFO' ).

lr_elem = lr_node->get_element( ).

lr_elem->get_attribute(

exporting

name = 'GENDER'

importing

value = item_gender ).

<b>endmethod.</b>

When I select 'Male', item_gender will have 'key1', and it will be set to 'key2' when I select Female. The context attribute 'gender' is of type char04.

Get back if you have any more issues.

Regards,

Nithya

Former Member
0 Kudos

Hi Nitya,

I hav doen the same which u mentioned. i followed as it is. i did the same. even i m not. if i select it, its not selecting.

Answers (1)

Answers (1)

Former Member
0 Kudos

Have you bound the selectedKey property of your radio button to your context attribute? In your onAction, you write this:

data: lr_node type ref to if_wd_context_node,

lr_elem type ref to if_wd_context_element,

item_gender type <data type of gender attribute>.

lr_node = wd_context->get_child_node( 'USER_GENERAL_INFO' ).

lr_elem = lr_node->get_element( ).

lr_elem->get_attribute(

exporting

name = 'GENDER'

importing

value = item_gender ).

The field item_gender will hold the selected key, i.e key1 or key2.

Regards

Nithya