cancel
Showing results for 
Search instead for 
Did you mean: 

Radio button validation

Former Member
0 Kudos

Hi Experts,

Can any one please tel me how to validate radiobutton groupbyindex...

and what is the cardinality for that.........

Thanks in advance

Accepted Solutions (0)

Answers (1)

Answers (1)

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi

Create a node of cardinality 0..n

create an attribute of type string under the node

fill the node in wddoinit ( rbtngrp1 is the node name and texts is the attribute name under the node )

data:

lt_attributes type standard table of if_radiobtngrpbyidx=>element_rbtngrp1,

wa_attributes like line of lt_attributes.

wa_attributes-texts = 'Radiobutton 1'.

insert wa_attributes into table lt_attributes.

wa_attributes-texts = 'Radiobutton 2'.

insert wa_attributes into table lt_attributes.

wa_attributes-texts = 'Radiobutton 3'.

insert wa_attributes into table lt_attributes.

Abhi

node->bind_elements( lt_attributes ).

Former Member
0 Kudos

First thing is this when I am setting cardinality 0..n Its giving error like....access to null object reference....

And I have created radio button wit cardinality 1..n but unable to validate..it ....

Do you have any idea if both of them are not selected the how do I show error message..

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi

Please go through the component WDR_TEST_EVENTS

You can get to know the UI elements are being used.

If you are getting the error null object reference, then it must be something wrong with your code.

you have to fill your context in WDDOINIT() method - refer my previous post

I Assume Validating means:

Knowing which radiobutton is selected at runtime, it is the lead selection.

Abhi

Former Member
0 Kudos

No Validation means....If none of the radio button is selected the I have to show error message.....

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi

You are able to view the radio buttons.

use this code to check whether any radiobutton is clicked

data: lr_rb type ref to if_wd_context_node.

data: lt_table type WDR_CONTEXT_ELEMENT_SET.

data: lr_element type ref to if_wd_context_element.

data: isselected type c.

lr_rb = wd_context->get_child_node( '<node_name>' ).

lt_table = lr_rb->get_elements( ).

loop at lt_table into lr_element.

if lr_element->isselected( ).

isselected = 'X'.

endif.

endloop.

if isselected is initial.

< none is selected >

endif.

Abhi