cancel
Showing results for 
Search instead for 
Did you mean: 

how to handle the visibility of a button from radio button

former_member205624
Contributor
0 Kudos

Hi, All

Please help me out I have to control the visibility of a button control from the click of a radio button.

Regards,

Jitender

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

First, decide if you want to make the button invisible or only disabled. Making it invisible might irritate the user.

To control the visibility, do this

1. Create a context attribute "ButtonVisibility" of type com.sap.ide.webdynpro.uielementdefinitions.Visibility (not Java native type WDVisibility)

2. Bind the "visible" property of the button to this context attribute.

3. Create an action to handle the radio button "onSelect" event. Set the "onSelect" property of the button to this action.

4. In the action handler, set the value of "ButtonVisibility" to WDVisibility.NONE or WDVisibility.VISIBLE.

To determine which radio button has been selected, you can look at the value of the context attribute that stores the selected key for the radio buttons (all "selectedKey" properties of the radio buttons in a group must be bound to the same context attribute)

Armin

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

First create an attribute 'buttonVisibiltiy' of type 'com.sap.ide.webdynpro.uielementdefinitions.Visibility' that u will find in Dictionary types, on clicking the button next to the 'type' property of a value attribute.

Create two radio buttons. Bind the 'selectedKey' property to a value attribute ('key') of type string. Now set 'keyToSelect' property of one radio button as 'r1' and another 'r2'.

Create an event say (selectRadio) and assign it to the 'onSelect' property of both radio buttons. Write following code:

if(wdContext.currentContextElement().getKey().equalsIgnoreCase("r1"))

{

wdContext.currentContextElement().setButtonVisibility(WDVisibility.VISIBLE);

}

else

{

wdContext.currentContextElement().setButtonVisibility(WDVisibility.NONE);

}

Regards,

Piyush.

Former Member
0 Kudos

HI Jithender,

If u have 2 radio buttons and u want the second radio button to be enabled then we have to set the properties like(First we have to create 3 attributes in context say R1,R2,Sel.)

RADIOBUTTON1:

Under properties

keyToselect : R1

selectedKey : Sel

RADIOBUTTON2:

Under properties

keyToselect : R2

selectedKey : Sel

under initilization

public void wdDoInit()

{

//@@begin wdDoInit()

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

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

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

//@@end

}

so if we deploy this the second radiobutton will be enabled by deafult.

If we want the first Radio button to be enable by default then we have to change to

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

During run time if we selecte the radio button its value will change automatically to the selected button value.

Hope ur satisfied.Pls reward points if ur satified with this.

REGARDS,

KrishnamRaju.