cancel
Showing results for 
Search instead for 
Did you mean: 

how to display UI elements dynamically on the click of a radiobutton

Former Member
0 Kudos

hi all,

I have created two radio buttons rb1, rb2 dynamically. If i click on rb1, ......

one label, one inputfield (ie., some UI elements ) must be displayed in the same view & if i click on rb2, other UI elements must display.

can anyone tell how to display UI elements which were created dynamically on the click of a radio button.

thanks & regards,

vila

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

1. Create a context attribute name visible1 of type type com.sap.ide.webdynpro.uielementdefinitions.Visibility(using brose button in the type property of context)

2. Bind this context to all tha elements of that you want to make visible when radio button 1 is clicked to their visibility property.

3. Create a context attribute name visible2 of type com.sap.ide.webdynpro.uielementdefinitions.Visibility(using brose button in the type property of context)

4. Bind this context to all tha elements of that you want to make visible when radio button 2 is clicked to their visibility property.

5. Create actions for both radio button1 say action1 and for radio button2 say action2.

6. In action1 write this line of code

wdContext.currentContextElement.setVisible1(WDVisibility.VISIBLE);

wdContext.currentContextElement.setVisible2(WDVisibility.BLANK);

7. In action2 write this line of code

wdContext.currentContextElement.setVisible2(WDVisibility.VISIBLE);

wdContext.currentContextElement.setVisible1(WDVisibility.BLANK);

Regards,

Murtuza

Former Member
0 Kudos

hi Murtuza,

I created two attributes & applied visibility property for those two attributes.

is it possible to create an action & event for the radiobutton dynamically?

if so ... how can we create? pls provide code for that

thanks,

vila

Former Member
0 Kudos

Hi Vila,

You can create an action dynamically in WDDoModifyView but i can't understand where will you mention the code of your action.

So I am illustrating the way you can bind any action to your radiobutton at runtime.

Assume you have two actions action1 and action2

In WDDoModifyView()

// creating a radio button dynamically.

IWDRadioButton rad = (IWDRadioButton)view.createElement

(IWDRadioButton.class,"Radio1");

// Getting an instance of a radio button being defined at desing time names Radio1

IWDRadioButton rad1 = (IWDRadioButton)view.getElement("Radio1");

rad.setOnSelect("Action1");//to bind action1

rad.setOnSelect("Action2");//to bind action2

Regards,

Murtuza

Former Member
0 Kudos

Hi Murtuza,

Instead of creating action1 for rb1 & action2 for rb2 at designtime, can we create action1 for radiobutton1 & action2 for radiobutton2 at runtime?

i created two radio buttons rb1, rb2. now i want to create action1 for rb1 & action2 for rb2 at runtime.

after creating action for rb1, if i click on rb1, it must display some UI elements which were created dynamically & if i click on rb2, it must display some UI elements dynamically. ps suggest me how to do this?

Former Member
0 Kudos

Hi Vila,

You can create actions like this dynamically

IWDAction act = (IWDAction)view.createElement(IWDAction.class,"Action1");

but where to write the code for this action, i am not aware of this.

he above line will create an action for you at runtime.

I showed you how to set the action to radio button in the previous reply, you can follow the same.

Regards,

Murtuza