cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to change the buttons text dynamically in Web Dynpro Java?

Former Member
0 Kudos

Hi,

I am developing a Web Dynpro Java application for my project at the client site. We have a requirement in our project that we should display 3 buttons in the table. There are 5 buttons and actions associated with them. But, depending on the conditionsl we should only display 3 buttons in the table. There are 3 columns meant for the buttons.

What are the possible choices? Should I change the button texts dynamically based on the conditions. If so how to achieve changing the button text dynamically?

Or are there any other ways that I can achieve this?

You replies are highly appreciated.

Regards

Ram

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Ram,

You have mentioned that you have 5 buttons and actions assosiated with them.

If the actions to be performed is different on click of each of these buttons then just changing the text of a button does not help.

First approch

You have to display the necessary 3 buttons and hide the remaining 2.

1.For this you need to have five different columns each for a different button.

2.Add one button into each of the column.

3.Add 5 additional context attribute of type "com.sap.ide.webdynpro.uielementdefinitions.Visibility", to the node bound to the table. One for each button.

4.Bind these attributes to the "visibility" property of the corresponding button.

5.Set the attribute with WDVisibility.NONE if the corresponding button has to be hidden, else set it as WDVisibility.VISIBLE.

Second approch

1. Have only three buttons as you have done now.

2. Add 3 context arrtribtes of type "String", to the node bound to the table. One for each button.

3. Bind these attributes to the "text" property of the corresponding button.

4. Set the text to be displayed on each of the buttons into these attributes.

5. Have a single action for all these buttons. In this method based on the name of the button clicked, perform appropriate action.

Hope one of these will help you.

Regards,

Vishweshwara P.K.M

Edited by: Vishweshwara P.K.M on Nov 12, 2010 11:33 AM

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Ram,

You can create 3 static buttons and depending on the condition, you can dynamically bind the text and the action.

The link below lists all the APIs that can be used for IWDButton.

http://help.sap.com/saphelp_nw04/helpdata/en/62/832cf3cd35004aa4ea8a2378c8a2be/frameset.htm

Let me know if you have any further questions.

Warm regards,

Rashmi

Former Member
0 Kudos

Also to change the button text dynamically, first create a context variable of type string and bind it to the text property of the button. Then conditionally you can set the context variable to the desired value.

e.g.if ( //your condition//)

wdContext.currentContextElement.setButtonText("Execute");

else

wdContext.currentContextElement.setButtonText("Cancel");

Where Buttontext is your context variable of type string.

Hope this helps.